diff --git a/public/.htaccess b/public/.htaccess
index 3f4e906..49b98f7 100644
--- a/public/.htaccess
+++ b/public/.htaccess
@@ -24,7 +24,6 @@ RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*)&?page=1$
RewriteRule ^(.*)/?$ /$1?%1%2 [R=301,L] #remove page=1 from url
-RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
diff --git a/public/store/controller/extension/feed/google_sitemap.php b/public/store/controller/extension/feed/google_sitemap.php
index 7cb7d37..2dd94e0 100644
--- a/public/store/controller/extension/feed/google_sitemap.php
+++ b/public/store/controller/extension/feed/google_sitemap.php
@@ -7,21 +7,28 @@ class ControllerExtensionFeedGoogleSitemap extends Controller {
$this->load->model('catalog/product');
$this->load->model('tool/image');
+ $this->load->model('localisation/zone');
$products = $this->model_catalog_product->getProducts();
+ $zones = $this->model_localisation_zone->getZonesByCountryId($this->config->get('config_country_id'));
+
+ if (!$zones) {
+ $zones[] = $this->model_localisation_zone->getZone($this->config->get('config_zone_id'));
+ }
foreach ($products as $product) {
- if ($product['image']) {
+ $product_url = $this->url->link('product/product', 'product_id=' . $product['product_id']);
+
+ if (!$this->hasSeoUrl($product_url)) {
+ continue;
+ }
+
+ foreach ($zones as $zone) {
$output .= '';
- $output .= ' ' . $this->url->link('product/product', 'product_id=' . $product['product_id']) . '';
+ $output .= ' ' . $this->escapeUrl($this->model_localisation_zone->getZoneUrlByZone($zone, $product_url)) . '';
$output .= ' weekly';
$output .= ' ' . date('Y-m-d\TH:i:sP', strtotime($product['date_modified'])) . '';
$output .= ' 1.0';
- $output .= ' ';
- $output .= ' ' . $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height')) . '';
- $output .= ' ' . $product['name'] . '';
- $output .= ' ' . $product['name'] . '';
- $output .= ' ';
$output .= '';
}
}
@@ -36,20 +43,11 @@ class ControllerExtensionFeedGoogleSitemap extends Controller {
foreach ($manufacturers as $manufacturer) {
$output .= '';
- $output .= ' ' . $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id']) . '';
+ $output .= ' ' . $this->escapeUrl($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id'])) . '';
$output .= ' weekly';
$output .= ' 0.7';
$output .= '';
- $products = $this->model_catalog_product->getProducts(array('filter_manufacturer_id' => $manufacturer['manufacturer_id']));
-
- foreach ($products as $product) {
- $output .= '';
- $output .= ' ' . $this->url->link('product/product', 'manufacturer_id=' . $manufacturer['manufacturer_id'] . '&product_id=' . $product['product_id']) . '';
- $output .= ' weekly';
- $output .= ' 1.0';
- $output .= '';
- }
}
$this->load->model('catalog/information');
@@ -58,7 +56,7 @@ class ControllerExtensionFeedGoogleSitemap extends Controller {
foreach ($informations as $information) {
$output .= '';
- $output .= ' ' . $this->url->link('information/information', 'information_id=' . $information['information_id']) . '';
+ $output .= ' ' . $this->escapeUrl($this->url->link('information/information', 'information_id=' . $information['information_id'])) . '';
$output .= ' weekly';
$output .= ' 0.5';
$output .= '';
@@ -84,24 +82,22 @@ class ControllerExtensionFeedGoogleSitemap extends Controller {
}
$output .= '';
- $output .= ' ' . $this->url->link('product/category', 'path=' . $new_path) . '';
+ $output .= ' ' . $this->escapeUrl($this->url->link('product/category', 'path=' . $new_path)) . '';
$output .= ' weekly';
$output .= ' 0.7';
$output .= '';
- $products = $this->model_catalog_product->getProducts(array('filter_category_id' => $result['category_id']));
-
- foreach ($products as $product) {
- $output .= '';
- $output .= ' ' . $this->url->link('product/product', 'path=' . $new_path . '&product_id=' . $product['product_id']) . '';
- $output .= ' weekly';
- $output .= ' 1.0';
- $output .= '';
- }
-
$output .= $this->getCategories($result['category_id'], $new_path);
}
return $output;
}
+
+ protected function escapeUrl($url) {
+ return htmlspecialchars(html_entity_decode($url, ENT_QUOTES, 'UTF-8'), ENT_QUOTES | ENT_XML1, 'UTF-8');
+ }
+
+ protected function hasSeoUrl($url) {
+ return basename((string)parse_url(str_replace('&', '&', $url), PHP_URL_PATH)) !== 'index.php';
+ }
}
diff --git a/public/store/model/localisation/zone.php b/public/store/model/localisation/zone.php
index f9b76c2..e2ff755 100644
--- a/public/store/model/localisation/zone.php
+++ b/public/store/model/localisation/zone.php
@@ -90,6 +90,10 @@ class ModelLocalisationZone extends Model {
public function getZoneUrl($zone_id, $url) {
$zone = $this->getZone($zone_id);
+ return $this->getZoneUrlByZone($zone, $url);
+ }
+
+ public function getZoneUrlByZone($zone, $url) {
if (!$zone) {
return $url;
}