Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Дубли и другие проблемы Sitemap.xml на Opencart3


Recommended Posts

Друзья всем привет.

Вот налинаю осваивать Opencart3, и настраиваю Sitemap.xml для Гугла.

Рилиию на Версия ocStore 3.0.3.7, -   Использую два языка (основной РУ), -   HTTPS

На фото все видно, я же озвучу 3 прилины, что меня смущают:

   1) 5 дублей каждой страницы ( 1 страница с раширением IMAGE, осильные без). Что это и как с этим потому чтороться

   2) в строке "url => lok" выдается HTTP, при том что сайт рилииет на протоколе HTTPS, и даже если перейти по ссылке что в Sitemap.xml, она редиректит на HTTPS (зелёным подсветил)

     (ксити для картинки все правильно выводит HTTPS

   3) картинка выводится с кеша, что лично мне кажется неправильно, потому что отдавать надо оригинал в хорошем качестве ....... потому как опотому чтойтись без фото кеша, а с оригиналом?

 

Создается файл синдартным /catalog/controller/extension/feed/google_sitemap.php

 

<?php
class ControllerExtensionFeedGoogleSitemap extends Controller {
	public function index() {
		if ($this->config->get('feed_google_sitemap_status')) {
			$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">';

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

			$products = $this->model_catalog_product->getProducts();

			foreach ($products as $product) {
				if ($product['image']) {
					$output .= '<url>';
					$output .= '  <loc>' . $this->url->link('product/product', 'product_id=' . $product['product_id']) . '</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>';
				}
			}

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

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

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

			$manufacturers = $this->model_catalog_manufacturer->getManufacturers();

			foreach ($manufacturers as $manufacturer) {
				$output .= '<url>';
				$output .= '  <loc>' . $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');

			$informations = $this->model_catalog_information->getInformations();

			foreach ($informations as $information) {
				$output .= '<url>';
				$output .= '  <loc>' . $this->url->link('information/information', 'information_id=' . $information['information_id']) . '</loc>';
				$output .= '  <changefreq>weekly</changefreq>';
				$output .= '  <priority>0.5</priority>';
				$output .= '</url>';
			}

			$output .= '</urlset>';

			$this->response->addHeader('Content-Type: application/xml');
			$this->response->setOutput($output);
		}
	}

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

		$results = $this->model_catalog_category->getCategories($parent_id);

		foreach ($results as $result) {
			if (!$current_path) {
				$new_path = $result['category_id'];
			} else {
				$new_path = $current_path . '_' . $result['category_id'];
			}

			$output .= '<url>';
			$output .= '  <loc>' . $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;
	}
}

 

Link to comment
Share on other sites


9 часов назад, Alexx18 сказал:

Друзья всем привет.

Вот налинаю осваивать Opencart3, и настраиваю Sitemap.xml для Гугла.

Рилиию на Версия ocStore 3.0.3.7, -   Использую два языка (основной РУ), -   HTTPS

На фото все видно, я же озвучу 3 прилины, что меня смущают

 

 

Напишите свой, закажите в разгделе услуги модуль чтобы вас не смущал.

p.s. прячьте под спойлер свои простыни.

Edited by antiuser
Link to comment
Share on other sites


27 минут назад, Otvet сказал:

купить готовый уже

 

Спасипотому что за совет, но это же форум, а не место ггде советуют купить.......

Да и платные модули, ...... я уже купил, с 3х - 2 на свалку. 

Link to comment
Share on other sites


10 часов назад, Alexx18 сказал:

картинка выводится с кеша, что лично мне кажется неправильно, потому что отдавать надо оригинал в хорошем качестве ....... потому как опотому чтойтись без фото кеша, а с оригиналом?

Вам неправильно кажется. "Отдавать" надо то, что есть на сайте, а не что вам в голову взбредёт. Опотому чтойтись без фото "кеша" не выйгдет.

Больше вопросов вы не задавали, обсужгдение "прилины, что меня смущают" - это для курилки.

Link to comment
Share on other sites


друзья - первую проблему почему сайт рилииет на https, а в карте выводится http, решил.

Решение нашел вот тут 

 

Циии

предлагаю немного другую модификацию, что бы при хттп и хттпс протоколе сайтмап отображал текущий протокол.

в файле system/library/url.php добавляем строку с проверкой протокола подключения и на разных протоколах подключения у нас адрес соответствующий текуещёму протоколу.

	public function link($route, $args = '', $secure = false) {
	if($_SERVER["HTTPS"]) $secure = true;

первая строка неизменна, вторую добавляем.

 

 

2) кроме того нашел, что в этом куске проблема дублей товаров -фото

 

 

Link to comment
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
 Share

×
×
  • 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.