protected function setSitemapProductImages(&$sitemap, $locale) { // Change timeout for this script ini_set('max_execution_time', Sitemap::getConfigValue('timeout', 30)); // Prepare query - get products URL $query = RewritingUrlQuery::create()->filterByView('product')->filterByRedirected(null)->filterByViewLocale($locale); // Join with visible products self::addJoinProductI18n($query); // Get products title & image file name $query->withColumn(ProductI18nTableMap::TITLE, 'PRODUCT_TITLE'); $query->addDescendingOrderByColumn(ProductImageTableMap::POSITION); $query->addGroupByColumn(RewritingUrlTableMap::VIEW_ID); $query->withColumn(ProductImageTableMap::FILE, 'PRODUCT_FILE'); // Execute query $results = $query->find(); // Get image generation configuration values $configValues = []; $configValues['width'] = Sitemap::getConfigValue('width'); $configValues['height'] = Sitemap::getConfigValue('height'); $configValues['quality'] = Sitemap::getConfigValue('quality', 75); $configValues['rotation'] = Sitemap::getConfigValue('rotation', 0); $configValues['resizeMode'] = Sitemap::getConfigValue('resize_mode', \Thelia\Action\Image::EXACT_RATIO_WITH_BORDERS); $configValues['bgColor'] = Sitemap::getConfigValue('background_color'); $configValues['allowZoom'] = Sitemap::getConfigValue('allow_zoom', false); // For each result, hydrate XML file /** @var RewritingUrl $result */ foreach ($results as $result) { // Generate image data $this->generateSitemapImage('product', $result, $configValues, $sitemap); } }
public function defaultAction() { if (null !== ($response = $this->checkAuth([AdminResources::MODULE], ["sitemap"], AccessManager::VIEW))) { return $response; } // Get resize mode name switch (Sitemap::getConfigValue('resize_mode')) { case 1: $resizeMode = 'borders'; break; case 2: $resizeMode = 'crop'; break; case 3: $resizeMode = 'none'; break; default: $resizeMode = ''; break; } // Build form $form = $this->createForm("sitemap_config_form", 'form', ['timeout' => Sitemap::getConfigValue('timeout'), 'width' => Sitemap::getConfigValue('width'), 'height' => Sitemap::getConfigValue('height'), 'quality' => Sitemap::getConfigValue('quality'), 'rotation' => Sitemap::getConfigValue('rotation'), 'resize_mode' => $resizeMode, 'background_color' => Sitemap::getConfigValue('background_color'), 'allow_zoom' => Sitemap::getConfigValue('allow_zoom')]); $this->getParserContext()->addForm($form); return $this->render("sitemap-configuration"); }