Skip to content

Commit

Permalink
Google sitemap fix
Browse files Browse the repository at this point in the history
- добавлена ссылка для главной страницы
- устранены дублированные сылки на товары, формируемые относительно
производителей и неосновным категориям
  • Loading branch information
ocshop committed Sep 5, 2014
1 parent ef83d7b commit d2ac62c
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions upload/catalog/controller/feed/google_sitemap.php
Expand Up @@ -4,6 +4,13 @@ public function index() {
if ($this->config->get('google_sitemap_status')) {
$output = '<?xml version="1.0" encoding="UTF-8"?>';
$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

$output .= '<url>';
$output .= '<loc>' . HTTP_SERVER . '</loc>';
$output .= '<changefreq>weekly</changefreq>';
$output .= '<priority>1.0</priority>';
$output .= '</url>';

$this->load->model('catalog/product');

$products = $this->model_catalog_product->getProducts();
Expand All @@ -16,8 +23,6 @@ public function index() {
$output .= '</url>';
}

$this->load->model('catalog/category');

$output .= $this->getCategories(0);

$this->load->model('catalog/manufacturer');
Expand All @@ -31,22 +36,12 @@ public function index() {
$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('blog/news');

$output .= $this->getBlogCategories(0);



$this->load->model('blog/article');

$articles = $this->model_blog_article->getArticles();
Expand Down Expand Up @@ -80,6 +75,9 @@ public function index() {
}

protected function getCategories($parent_id, $current_path = '') {

$this->load->model('catalog/category');

$output = '';

$results = $this->model_catalog_category->getCategories($parent_id);
Expand All @@ -97,16 +95,6 @@ protected function getCategories($parent_id, $current_path = '') {
$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);
}

Expand Down

0 comments on commit d2ac62c

Please sign in to comment.