карта сайта

This commit is contained in:
Konstantin
2026-06-01 17:21:43 +03:00
parent dc947f50f5
commit b250f38d42
3 changed files with 29 additions and 30 deletions
@@ -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 .= '<url>';
$output .= ' <loc>' . $this->url->link('product/product', 'product_id=' . $product['product_id']) . '</loc>';
$output .= ' <loc>' . $this->escapeUrl($this->model_localisation_zone->getZoneUrlByZone($zone, $product_url)) . '</loc>';
$output .= ' <changefreq>weekly</changefreq>';
$output .= ' <lastmod>' . date('Y-m-d\TH:i:sP', strtotime($product['date_modified'])) . '</lastmod>';
$output .= ' <priority>1.0</priority>';
$output .= ' <image:image>';
$output .= ' <image:loc>' . $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')) . '</image:loc>';
$output .= ' <image:caption>' . $product['name'] . '</image:caption>';
$output .= ' <image:title>' . $product['name'] . '</image:title>';
$output .= ' </image:image>';
$output .= '</url>';
}
}
@@ -36,20 +43,11 @@ class ControllerExtensionFeedGoogleSitemap extends Controller {
foreach ($manufacturers as $manufacturer) {
$output .= '<url>';
$output .= ' <loc>' . $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id']) . '</loc>';
$output .= ' <loc>' . $this->escapeUrl($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id'])) . '</loc>';
$output .= ' <changefreq>weekly</changefreq>';
$output .= ' <priority>0.7</priority>';
$output .= '</url>';
$products = $this->model_catalog_product->getProducts(array('filter_manufacturer_id' => $manufacturer['manufacturer_id']));
foreach ($products as $product) {
$output .= '<url>';
$output .= ' <loc>' . $this->url->link('product/product', 'manufacturer_id=' . $manufacturer['manufacturer_id'] . '&product_id=' . $product['product_id']) . '</loc>';
$output .= ' <changefreq>weekly</changefreq>';
$output .= ' <priority>1.0</priority>';
$output .= '</url>';
}
}
$this->load->model('catalog/information');
@@ -58,7 +56,7 @@ class ControllerExtensionFeedGoogleSitemap extends Controller {
foreach ($informations as $information) {
$output .= '<url>';
$output .= ' <loc>' . $this->url->link('information/information', 'information_id=' . $information['information_id']) . '</loc>';
$output .= ' <loc>' . $this->escapeUrl($this->url->link('information/information', 'information_id=' . $information['information_id'])) . '</loc>';
$output .= ' <changefreq>weekly</changefreq>';
$output .= ' <priority>0.5</priority>';
$output .= '</url>';
@@ -84,24 +82,22 @@ class ControllerExtensionFeedGoogleSitemap extends Controller {
}
$output .= '<url>';
$output .= ' <loc>' . $this->url->link('product/category', 'path=' . $new_path) . '</loc>';
$output .= ' <loc>' . $this->escapeUrl($this->url->link('product/category', 'path=' . $new_path)) . '</loc>';
$output .= ' <changefreq>weekly</changefreq>';
$output .= ' <priority>0.7</priority>';
$output .= '</url>';
$products = $this->model_catalog_product->getProducts(array('filter_category_id' => $result['category_id']));
foreach ($products as $product) {
$output .= '<url>';
$output .= ' <loc>' . $this->url->link('product/product', 'path=' . $new_path . '&product_id=' . $product['product_id']) . '</loc>';
$output .= ' <changefreq>weekly</changefreq>';
$output .= ' <priority>1.0</priority>';
$output .= '</url>';
}
$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('&amp;', '&', $url), PHP_URL_PATH)) !== 'index.php';
}
}
+4
View File
@@ -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;
}