From 0b451e2fc2158d082379d8eb3038e79e693c3201 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 19 Mar 2018 11:57:01 +0100 Subject: [PATCH] Mask all pages --- modules/googlesitemap/googlesitemap.php | 44 +++++++++++++------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/modules/googlesitemap/googlesitemap.php b/modules/googlesitemap/googlesitemap.php index 185b1b71..285f8a5a 100755 --- a/modules/googlesitemap/googlesitemap.php +++ b/modules/googlesitemap/googlesitemap.php @@ -119,7 +119,7 @@ XML; } /* Categories Generator */ - $exclude_categories = array(); + /*$exclude_categories = array(); if (Module::isInstalled('privatesales')) { include(dirname(__FILE__).'/../privatesales/Sale.php'); $has_trailers = file_exists(dirname(__FILE__).'/../privatesales/trailer.php'); @@ -192,7 +192,7 @@ XML; } } } - } + }*/ /*if (Configuration::get('PS_REWRITING_SETTINGS')) { $categories = Db::getInstance()->ExecuteS(' @@ -226,7 +226,7 @@ XML; $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($category['date_upd'], 0, 10)); } - $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' + /*$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') date_upd, pl.id_lang, cl.`link_rewrite` category, ean13, i.id_image, il.legend legend_image, ( SELECT MIN(level_depth) FROM '._DB_PREFIX_.'product p2 @@ -254,29 +254,31 @@ XML; '.(count($exclude_categories) > 0? ' AND p.id_category_default NOT IN ('.implode(', ', $exclude_categories).')': '').' '.(Configuration::get('GSITEMAP_ALL_PRODUCTS') ? '' : 'HAVING level_depth IS NOT NULL').' ORDER BY pl.id_product, pl.id_lang ASC - '); + ');*/ $tmp = NULL; $res = NULL; - foreach($products as $product) { - if ($tmp == $product['id_product']) { - $res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']); - } else { - $tmp = $product['id_product']; - $res[$tmp] = $product; - unset($res[$tmp]['id_image'], $res[$tmp]['legend_image']); - $res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']); + if (count($products) > 0) { + foreach($products as $product) { + if ($tmp == $product['id_product']) { + $res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']); + } else { + $tmp = $product['id_product']; + $res[$tmp] = $product; + unset($res[$tmp]['id_image'], $res[$tmp]['legend_image']); + $res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']); + } } - } - - foreach($res as $product) { - if (($priority = 0.7 - ($product['level_depth'] / 10)) < 0.1) { - $priority = 0.1; + + foreach($res as $product) { + if (($priority = 0.7 - ($product['level_depth'] / 10)) < 0.1) { + $priority = 0.1; + } + + $tmpLink = $link->getProductLink((int) $product['id_product'], $product['link_rewrite'], $product['category'], $product['ean13'], (int) $product['id_lang']); + $sitemap = $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($product['date_upd'], 0, 10)); + $sitemap = $this->_addSitemapNodeImage($sitemap, $product); } - - $tmpLink = $link->getProductLink((int) $product['id_product'], $product['link_rewrite'], $product['category'], $product['ean13'], (int) $product['id_lang']); - $sitemap = $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($product['date_upd'], 0, 10)); - $sitemap = $this->_addSitemapNodeImage($sitemap, $product); } /* Add classic pages (contact, best sales, new products...) */