Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Sign Up

Модуль Simpl Qooqle Sitemap дублирует ссылки


Recommended Posts

Добрый день. Подскажите как исправить дубляж ссылок в Simpl Qooqle Sitemap. Отображает по 3-5 раз. 

 

<?php
class ControllerFeedSimpleGoogleSitemap extends Controller {
    public function index() {    
    $log = new Log('simple_google_sitemap.log');
        if ($this->config->get('google_sitemap_status')) {    
            $this->load->model('feed/simple_google_sitemap');
            $this->load->model('tool/image');  
      $args = array(
        'language_id' => (int)$this->config->get('config_language_id'),
        'store_id' => (int)$this->config->get('config_store_id')
      );
      
      $start = microtime(true);    
            $output  = '<?xml version="1.0" encoding="UTF-8"?>';
            $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
            $output .= "\n";

            $products = $this->model_feed_simple_google_sitemap->getProducts($args);    
      if ($products) {
        foreach ($products as $product) {
          $output .= "<url>\n";
          $output .= "  <loc>" . $this->url->link('product/product', 'product_id=' . $product['product_id']) . "</loc>\n";
          $output .= "  <lastmod>" . $product['date_modified'] . "</lastmod>\n";
          $output .= "  <changefreq>weekly</changefreq>\n";
          $output .= "  <priority>1.0</priority>\n";
          if (!empty($product['image']) && is_file(DIR_IMAGE.$product['image'])) {
            $output .= "  <image:image>\n";
            $output .= '    <image:loc>' . @$this->model_tool_image->resize($product['image'],$this->config->get('config_image_popup_width'),$this->config->get('config_image_popup_height')) . "</image:loc>\n";
            $output .= '    <image:caption>' . str_replace('&','&amp;',$product['name']) . "</image:caption>\n";
            $output .= '    <image:title>' .  str_replace('&','&amp;',$product['name']) . "</image:title>\n";
            $output .= "  </image:image>\n";
          }
          $output .= "</url>\n";
        }
      }
      
            $categories = $this->model_feed_simple_google_sitemap->getCategories($args);  
      if ($categories) {
        foreach ($categories as $category) {
          $output .= "<url>\n";
          $output .= "  <loc>" . $this->url->link('product/category', 'category_id=' . $category['category_id']) . "</loc>\n";  
          $output .= "  <lastmod>" . $category['date_modified'] . "</lastmod>\n";
          $output .= "  <changefreq>weekly</changefreq>\n";
          $output .= "  <priority>0.7</priority>\n";
          $output .= "</url>\n";
        }
      }  
      
            $manufacturers = $this->model_feed_simple_google_sitemap->getManufacturers($args);   
      if ($manufacturers) {
        foreach ($manufacturers as $manufacturer) {
          $output .= "<url>\n";
          $output .= '  <loc>' . $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id']) . "</loc>\n";
          $output .= "  <changefreq>weekly</changefreq>\n";
          $output .= "  <priority>0.7</priority>\n";
          $output .= "</url>\n";
        }
      }   
      
            $informations = $this->model_feed_simple_google_sitemap->getInformations($args); 
      if ($informations) {
        foreach ($informations as $information) {
          $output .= "<url>\n";
          $output .= '  <loc>' . $this->url->link('information/information', 'information_id=' . $information['information_id']) . "</loc>\n";
          $output .= "  <changefreq>weekly</changefreq>\n";
          $output .= "  <priority>0.5</priority>\n";
          $output .= "</url>\n";
        }       
      }   
      if ($this->config->get('news')) { 
        $news = $this->model_feed_simple_google_sitemap->getNews($args);   
        if ($news) {
          foreach ($news as $new) {
            $output .= "<url>\n";
            $output .= '  <loc>' . $this->url->link('information/information', 'information_id=' . $new['news_id']) . "</loc>\n";
            $output .= "  <changefreq>weekly</changefreq>\n";
            $output .= "  <priority>0.5</priority>\n";
            $output .= "</url>\n";
          }
        }
      }
            $output .= "</urlset>\n";

      $time = microtime(true) - $start;
      $log->write(sprintf('Sitemap was generated for %.4F s. ', $time).'Request from '.$_SERVER["REMOTE_ADDR"].' '.$_SERVER['HTTP_USER_AGENT']);
      
            $this->response->addHeader('Content-Type: application/xml');
            $this->response->setOutput($output);       
        }
    }

}
 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.