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

Canonical для пагинации


 Share

Recommended Posts

Всем привет. Заметил что в 3 опенкарте не правильно почему то срабатывает каноникал для страниц категории

В контроллере такой код

			if ($page == 1) {
			    $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
			} else {
				$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), 'canonical');
			}
			
			if ($page > 1) {
			    $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . (($page - 2) ? '&page='. ($page - 1) : '')), 'prev');
			}

			if ($limit && ceil($product_total / $limit) > $page) {
			    $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1)), 'next');
			}

но на станице каноникал как для второй страницы (в прикреплении)

 

Почему так? Разве не должна быть первая страница каноникал?

 

85c79b77a8264bcffb4271406451c314.png

Link to comment
Share on other sites


6 минут назад, spectre сказал:

image.png.eda9ccae39fd620cb0ad7ac77c054233.png

 

пробовал добавить после = 1, тогда страница получается  как ....golinnya/krem-dlja-britja/page-12" rel="canonical" />

 

а если удалить последущее ". $page" или все " . '&page='. $page" то тогда вообще строка с каноникал пропадает

Edited by btrotsky
Link to comment
Share on other sites


19 минут назад, spectre сказал:

значит что-то другое добавляет 

 

прошелся и поискал в файлах canonical и получил такой список https://gyazo.com/fdd83184b659d067f12e686764e9c408

 

думал может мегафильтр чтото делает и там удалил такой код

		self::removeLinksByRel( $ctrl, 'canonical' );
		
		$ctrl->document->addLink( self::addSeoAlias( $ctrl->url->link('product/category', 'path=' . $path, true), $alias ), 'canonical');

но все тоже самое

Link to comment
Share on other sites


3 часа назад, btrotsky сказал:

Всем привет. Заметил что в 3 опенкарте не правильно почему то срабатывает каноникал для страниц категории

Так и должно быть. Это такой вид канонизации в третьем ввели..

Если нужна канонизация страниц листинга "цепочкой" , то поставьте canonical-category-no-page.ocmod.zip вот отсюда:

 

Так же можете поставить этот модификатор (сами запакуете): https://github.com/optimlab/optimblog/tree/master/canonical-manufacturer.ocmod

Link to comment
Share on other sites

16 часов назад, Yesvik сказал:

Смотри в модифицированных файлах

 

смотрел, не нашел

 

15 часов назад, optimlab сказал:

Так и должно быть. Это такой вид канонизации в третьем ввели..

Если нужна канонизация страниц листинга "цепочкой" , то поставьте canonical-category-no-page.ocmod.zip вот отсюда:

 

Так же можете поставить этот модификатор (сами запакуете): https://github.com/optimlab/optimblog/tree/master/canonical-manufacturer.ocmod

 

после установки вообще каноникал пропадает

 

12 часов назад, florapraktik сказал:

Почитайте Рекомендации Гугл для веб мастеров.

 

так причем тут рекомендации? мне нужно исправить каноникал на опенкарте, зачем мне рекомендации?

Link to comment
Share on other sites


15 часов назад, florapraktik сказал:

Почитайте Рекомендации Гугл для веб мастеров. 

Постраничная навигация в тройке не соответствует рекомендациям Гугл.

Нельзя страницы постраничной навигации объявлять каноническими.

Нельзя для второй и последующих страниц объявлять канонической первую страницу.

Link to comment
Share on other sites

В 2013 году Гугл давал разъяснения в официальном блоге.

Не  могу найти ссылку, если найду - выложу.

В двух словах Гугл рекомендует следующее: сделать страницу на которой будут все товары и указывать эту страницу как каноническую для всех ссылок постраничной навигации, от первой до последней.

Link to comment
Share on other sites

3 часа назад, Yesvik сказал:

 

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

Link to comment
Share on other sites


Если надо сделать вторую и последующие страницы не каноническими, а канонической объявить первую страницу тогда:

в контроллере категорий  вместо

if ($page == 1) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
} else {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page=' . $page), 'canonical');
}

сделай

if ($page == 1) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
} else {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), '');
}

 

В шаблоне шапки вместо

{% for link in links %}
<link href="{{ link.href }}" rel="{{ link.rel }}" />
{% endfor %}

сделай

{% for link in links %}
{% if link.rel %}
<link href="{{ link.href }}" rel="{{ link.rel }}" />
{% else %}
<link href="{{ link.href }}" />
{% endif %}
{% endfor %}

 

Link to comment
Share on other sites

1 час назад, Yesvik сказал:

Если надо сделать вторую и последующие страницы не каноническими, а канонической объявить первую страницу тогда:

в контроллере категорий  вместо

сделай


if ($page == 1) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
} else {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), '');
}

 

 

 

после этого страница категории выдает ошибку 500

 

[Sat Apr 20 20:34:17.188592 2019] [:error] [pid 30424] [client 194.44.86.115:56320] PHP Parse error:  syntax error, unexpected '$data' (T_VARIABLE) in /var/www/123/data/www/storage/modification/catalog/controller/product/category.php on line 430, referer: https://123.com/

 

Edited by btrotsky
Link to comment
Share on other sites


От изменений, которые я написал, такой ошибки быть не может. Посмотри в какой строке вносил изменения и на какую строку ругается...

Выложи сюда файл контроллера

storage/modification/catalog/controller/product/category.php
Link to comment
Share on other sites

16 минут назад, Yesvik сказал:

От изменений, которые я написал, такой ошибки быть не может. Посмотри в какой строке вносил изменения и на какую строку ругается...

Выложи сюда файл контроллера


storage/modification/catalog/controller/product/category.php

 

вот 

Спойлер

<?php
class ControllerProductCategory extends Controller {
	public function index() {
		$this->load->language('product/category');

			$uniset = $this->config->get('config_unishop2');
			$lang_id = $this->config->get('config_language_id');
			
			$this->load->language('extension/module/uni_othertext');
			
			$data['shop_name'] = $this->config->get('config_name');
			$data['heading_title'] = isset($uniset['show_heading_in_admin']) && isset($setting['name']) ? $setting['name'] : $this->language->get('heading_title');
			$module_type_view = isset($uniset['module_type_view']) ? $uniset['module_type_view'] : [];
			$data['type_view'] = isset($setting['name']) && in_array($setting['name'], $module_type_view) ? 'grid' : 'carousel';

			$data['menu_schema'] = isset($uniset['menu_schema']) && $uniset['menu_type'] == 1 ? $uniset['menu_schema'] : [];
			
			$data['show_grid_button'] = isset($uniset['show_grid_button']) ? true : false;
			$data['show_list_button'] = isset($uniset['show_list_button']) ? true : false;
			$data['show_compact_button'] = isset($uniset['show_compact_button']) ? true : false;		
			
			$data['show_quick_order_text'] = isset($uniset['show_quick_order_text']) ? $uniset['show_quick_order_text'] : '';			
			$data['quick_order_icon'] = isset($uniset['show_quick_order']) ? $uniset[$lang_id]['quick_order_icon'] : '';	
			$data['quick_order_title'] = isset($uniset['show_quick_order']) ? $uniset[$lang_id]['quick_order_title'] : '';
			$data['show_rating'] = isset($uniset['show_rating']) ? true : false;
			$data['wishlist_btn_disabled'] = isset($uniset['wishlist_btn_disabled']) ? true : false;
			$data['compare_btn_disabled'] = isset($uniset['compare_btn_disabled']) ? true : false;
			
			$currency = $this->session->data['currency'];
			$this->load->model('extension/module/uni_new_data');
			

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

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

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

			$data['cat_desc_pos'] = $uniset['cat_desc_pos'];
			$data['subcategory_column'] = isset($uniset['subcategory_column']) ? implode(' ', $uniset['subcategory_column']) : '';
			

		if (isset($this->request->get['filter'])) {
			$filter = $this->request->get['filter'];
		} else {
			$filter = '';
		}

		if (isset($this->request->get['sort'])) {
			$sort = $this->request->get['sort'];
		} else {
			$sort = 'p.sort_order';
		}

		if (isset($this->request->get['order'])) {
			$order = $this->request->get['order'];
		} else {
			$order = 'ASC';
		}

		if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
		}

		if (isset($this->request->get['limit'])) {
			$limit = (int)$this->request->get['limit'];
		} else {
			$limit = $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit');
		}

		$data['breadcrumbs'] = array();

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_home'),
			'href' => $this->url->link('common/home')
		);

		if (isset($this->request->get['path'])) {
			$url = '';

				if( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') ) {
					$url .= '&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=' . urlencode( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') );
				}
			

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['limit'])) {
				$url .= '&limit=' . $this->request->get['limit'];
			}

			$path = '';

			$parts = explode('_', (string)$this->request->get['path']);

				if( $this->rgetMFP('mfp_path') !== null ) {
					$parts = explode('_', (string)$this->rgetMFP('mfp_path'));
				}
			

			$category_id = (int)array_pop($parts);

			foreach ($parts as $path_id) {
				if (!$path) {
					$path = (int)$path_id;
				} else {
					$path .= '_' . (int)$path_id;
				}

				$category_info = $this->model_catalog_category->getCategory($path_id);

				if ($category_info) {
					$data['breadcrumbs'][] = array(
						'text' => $category_info['name'],
						'href' => $this->url->link('product/category', 'path=' . $path . $url)
					);
				}
			}
		} else {
			$category_id = 0;
		}

		$category_info = $this->model_catalog_category->getCategory($category_id);

		if ($category_info) {
			$this->document->setTitle($category_info['meta_title']);
			$this->document->setDescription($category_info['meta_description']);
			$this->document->setKeywords($category_info['meta_keyword']);

			if ($this->config->get('hb_snippets_og_enable') == '1'){
			$hb_snippets_ogc = $this->config->get('hb_snippets_ogc');
			if (strlen($hb_snippets_ogc) > 4){
				$ogc_name = $category_info['name'];
				$hb_snippets_ogc = str_replace('{name}',$ogc_name,$hb_snippets_ogc);
			}else{
				$hb_snippets_ogc = $category_info['name'];
			}
			
				$this->document->setOpengraph('og:title', $hb_snippets_ogc);
				$this->document->setOpengraph('og:type', 'website');
				$this->document->setOpengraph('og:site_name', $this->config->get('config_name'));
				$this->document->setOpengraph('og:image', HTTP_SERVER . 'image/' . $category_info['image']);
				$this->document->setOpengraph('og:url', $this->url->link('product/category', 'path=' . $this->request->get['path']));
				$this->document->setOpengraph('og:description', $category_info['meta_description']);
			}
			

			$data['heading_title'] = $category_info['name'];

			$data['text_compare'] = sprintf($this->language->get('text_compare'), (isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0));

			// Set the last category breadcrumb
			$data['breadcrumbs'][] = array(
				'text' => $category_info['name'],
				'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'])
			);


		if ($category_info['hd_description']) {
		if (!isset($this->request->get['page']) || $this->request->get['page'] == 1) {
	  
			if ($category_info['image']) {
				$data['thumb'] = $this->model_tool_image->resize($category_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_category_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_category_height'));
			} else {
				$data['thumb'] = '';
			}


		  }else{
			$data['thumb'] = '';
		  }
		}else{
		  if ($category_info['image']) {
			$data['thumb'] = $this->model_tool_image->resize($category_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_category_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_category_height'));
		  } else {
			$data['thumb'] = '';
		  }
		}
	  
			
		$data['rm_description'] = $category_info['rm_description'];
		$data['ht_description'] = $category_info['ht_description'];
		$data['ht_ext_description'] = $category_info['ht_ext_description'];
		$data['rm_ext_description'] = $category_info['rm_ext_description'];
		$data['rmm_ext_description'] = $category_info['rmm_ext_description'];

		if ($category_info['hd_description']) {
		  if (!isset($this->request->get['page']) || $this->request->get['page'] == 1) {
			$data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8');
		  }else{
			$data['description'] = '';
		  }
		}else{
		  $data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8');
		}

		if ($category_info['hd_ext_description']) {
		  if (!isset($this->request->get['page']) || $this->request->get['page'] == 1) {
			$data['ext_description'] = html_entity_decode($category_info['ext_description'], ENT_QUOTES, 'UTF-8');
		  }else{
			$data['ext_description'] = '';
		  }
		}else{
		  $data['ext_description'] = html_entity_decode($category_info['ext_description'], ENT_QUOTES, 'UTF-8');
		}
	  
			$data['compare'] = $this->url->link('product/compare');

			$url = '';

				if( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') ) {
					$url .= '&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=' . urlencode( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') );
				}
			

			if (isset($this->request->get['filter'])) {
				$url .= '&filter=' . $this->request->get['filter'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['limit'])) {
				$url .= '&limit=' . $this->request->get['limit'];
			}


				$fmSettings = $this->config->get('mega_filter_settings');
				
				if( $this->rgetMFP('mfp_path') !== null && false !== ( $mfpPos = strpos( $url, '&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=' ) ) ) {
					$mfSt = mb_strpos( $url, '&', $mfpPos+1, 'utf-8');
					$mfp = $mfSt === false ? $url : mb_substr( $url, $mfpPos, $mfSt-1, 'utf-8' );
					$url = $mfSt === false ? '' : mb_substr($url, $mfSt, mb_strlen( $url, 'utf-8' ), 'utf-8');				
					$mfp = preg_replace( '#path(\[[^\]]+\],?|,[^/]+/?)#', '', urldecode( $mfp ) );
					$mfp = preg_replace( '#&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=&|&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=#', '', $mfp );
					
					if( $mfp ) {
						$url .= '&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=' . urlencode( $mfp );
					}
				}
				
				if( ! empty( $fmSettings['not_remember_filter_for_subcategories'] ) && false !== ( $mfpPos = strpos( $url, '&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=' ) ) ) {
					$mfUrlBeforeChange = $url;
					$mfSt = mb_strpos( $url, '&', $mfpPos+1, 'utf-8');
					$url = $mfSt === false ? '' : mb_substr($url, $mfSt, mb_strlen( $url, 'utf-8' ), 'utf-8');
				} else if( empty( $fmSettings['not_remember_filter_for_subcategories'] ) && false !== ( $mfpPos = strpos( $url, '&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=' ) ) ) {
					$mfUrlBeforeChange = $url;
					$url = preg_replace( '/,?path\[[0-9_]+\]/', '', $url );
				}
			
			$data['categories'] = array();

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

			foreach ($results as $result) {
				$filter_data = array(
					'filter_category_id'  => $result['category_id'],
					'filter_sub_category' => true
				);

				$data['categories'][] = array(

			'thumb' => $this->model_tool_image->resize(($result['image'] == '' ? 'no_image.jpg' : $result['image']), $this->config->get('theme_'.$this->config->get('config_theme').'_image_category_width'), $this->config->get('theme_'.$this->config->get('config_theme').'_image_category_height')),
			
					'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
					'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
				);
			}


				if( isset( $mfUrlBeforeChange ) ) {
					$url = $mfUrlBeforeChange;
					unset( $mfUrlBeforeChange );
				}
			
			$data['products'] = array();

			$filter_data = array(
				'filter_category_id' => $category_id,
				'filter_filter'      => $filter,
				'sort'               => $sort,
				'order'              => $order,
				'start'              => ($page - 1) * $limit,
				'limit'              => $limit
			);


				$fmSettings = $this->config->get('mega_filter_settings');
		
				if( ! empty( $fmSettings['show_products_from_subcategories'] ) ) {
					if( ! empty( $fmSettings['level_products_from_subcategories'] ) ) {
						$fmLevel = (int) $fmSettings['level_products_from_subcategories'];
						$fmPath = explode( '_', empty( $this->request->get['path'] ) ? '' : $this->request->get['path'] );

						if( $fmPath && count( $fmPath ) >= $fmLevel ) {
							$filter_data['filter_sub_category'] = '1';
						}
					} else {
						$filter_data['filter_sub_category'] = '1';
					}
				}
				
				if( ! empty( $this->request->get['manufacturer_id'] ) ) {
					$filter_data['filter_manufacturer_id'] = (int) $this->request->get['manufacturer_id'];
				}
			

				$filter_data['mfp_overwrite_path'] = true;
			
			$product_total = $this->model_catalog_product->getTotalProducts($filter_data);

			$results = $this->model_catalog_product->getProducts($filter_data);

			foreach ($results as $result) {
				if ($result['image']) {
					$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
				} else {
					$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
				}

				if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
					$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
				} else {
					$price = false;
				}

				if ((float)$result['special']) {
					$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
				} else {
					$special = false;
				}

				if ($this->config->get('config_tax')) {
					$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
				} else {
					$tax = false;
				}

				if ($this->config->get('config_review_status')) {
					$rating = (int)$result['rating'];
				} else {
					$rating = false;
				}


			$setting = isset($setting) ? $setting : '';
			$result = isset($product_info) && $setting ? $product_info : $result;
			$new_data = $this->model_extension_module_uni_new_data->getNewData($result, $setting);
			$show_description = isset($uniset['show_description']) && !isset($uniset['show_description_alt']) || isset($uniset['show_description_alt']) && !$new_data['attributes'] ? true : false;
			
			if($new_data['special_date_end']) {
				$data['show_timer'] = true;
			}
			
			if($result['quantity'] > 0) {
				$show_quantity = isset($uniset['show_quantity_cat']) ? true : false;
				$cart_btn_icon = $uniset[$lang_id]['cart_btn_icon'];
				$cart_btn_text = $uniset[$lang_id]['cart_btn_text'];
				$cart_btn_class = '';
				$quick_order = isset($uniset['show_quick_order']) ? true : false;
			} else {
				$show_quantity = isset($uniset['show_quantity_cat_all']) ? true : false;
				$cart_btn_icon = $uniset[$lang_id]['cart_btn_icon_disabled'];
				$cart_btn_text = $uniset[$lang_id]['cart_btn_text_disabled'];
				$cart_btn_class = $uniset['cart_btn_disabled'];
				$quick_order = isset($uniset['show_quick_order_quantity']) ? true : false;
			}
			
				$data['products'][] = array(

			'additional_image'	=> $new_data['additional_image'],
			'num_reviews' 		=> isset($uniset['show_rating_count']) ? $result['reviews'] : '',
			'special_date_end' 	=> $new_data['special_date_end'],
			'minimum' 			=> $result['minimum'],
			'quantity_indicator'=> $new_data['quantity_indicator'],
			'stickers' 			=> $new_data['stickers'],
			'price_value' 		=> $this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))*$this->currency->getValue($currency),
			'special_value' 	=> $this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax'))*$this->currency->getValue($currency),
			'discounts'			=> $new_data['discounts'],
			'attributes' 		=> $new_data['attributes'],
			'options'			=> $new_data['options'],
			'show_description'	=> $show_description,
			'show_quantity'		=> $show_quantity,
			'cart_btn_icon'		=> $cart_btn_icon,
			'cart_btn_text'		=> $cart_btn_text,
			'cart_btn_class'	=> $cart_btn_class,
			'quick_order'		=> $quick_order,
			
					'product_id'  => $result['product_id'],
					'thumb'       => $image,
					'name'        => $result['name'],
					'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
					'price'       => $price,
					'special'     => $special,
					'tax'         => $tax,
					'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
					'rating'      => $result['rating'],
					'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
				);
			}

			$url = '';

				if( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') ) {
					$url .= '&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=' . urlencode( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') );
				}
			

			if (isset($this->request->get['filter'])) {
				$url .= '&filter=' . $this->request->get['filter'];
			}

			if (isset($this->request->get['limit'])) {
				$url .= '&limit=' . $this->request->get['limit'];
			}

			$data['sorts'] = array();

			$data['sorts'][] = array(
				'text'  => $this->language->get('text_default'),
				'value' => 'p.sort_order-ASC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC' . $url)
			);

			$data['sorts'][] = array(
				'text'  => $this->language->get('text_name_asc'),
				'value' => 'pd.name-ASC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=pd.name&order=ASC' . $url)
			);

			$data['sorts'][] = array(
				'text'  => $this->language->get('text_name_desc'),
				'value' => 'pd.name-DESC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=pd.name&order=DESC' . $url)
			);

			$data['sorts'][] = array(
				'text'  => $this->language->get('text_price_asc'),
				'value' => 'p.price-ASC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.price&order=ASC' . $url)
			);

			$data['sorts'][] = array(
				'text'  => $this->language->get('text_price_desc'),
				'value' => 'p.price-DESC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.price&order=DESC' . $url)
			);

			if ($this->config->get('config_review_status')) {
				$data['sorts'][] = array(
					'text'  => $this->language->get('text_rating_desc'),
					'value' => 'rating-DESC',
					'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=rating&order=DESC' . $url)
				);

				$data['sorts'][] = array(
					'text'  => $this->language->get('text_rating_asc'),
					'value' => 'rating-ASC',
					'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=rating&order=ASC' . $url)
				);
			}

			$data['sorts'][] = array(
				'text'  => $this->language->get('text_model_asc'),
				'value' => 'p.model-ASC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.model&order=ASC' . $url)
			);

			$data['sorts'][] = array(
				'text'  => $this->language->get('text_model_desc'),
				'value' => 'p.model-DESC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.model&order=DESC' . $url)
			);

			$url = '';

				if( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') ) {
					$url .= '&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=' . urlencode( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') );
				}
			

			if (isset($this->request->get['filter'])) {
				$url .= '&filter=' . $this->request->get['filter'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			$data['limits'] = array();

			$limits = array_unique(array($this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'), 25, 50, 75, 100));

			sort($limits);

			foreach($limits as $value) {
				$data['limits'][] = array(
					'text'  => $value,
					'value' => $value,
					'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&limit=' . $value)
				);
			}

			$url = '';

				if( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') ) {
					$url .= '&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=' . urlencode( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') );
				}
			

			if (isset($this->request->get['filter'])) {
				$url .= '&filter=' . $this->request->get['filter'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['limit'])) {
				$url .= '&limit=' . $this->request->get['limit'];
			}

			$pagination = new Pagination();
			$pagination->total = $product_total;
			$pagination->page = $page;
			$pagination->limit = $limit;
			$pagination->url = $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&page={page}');

			$data['pagination'] = $pagination->render();

			$data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($product_total - $limit)) ? $product_total : ((($page - 1) * $limit) + $limit), $product_total, ceil($product_total / $limit));

			// http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html
if ($page == 1) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
} else {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), '');
}
			
			if ($page > 1) {
			    $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . (($page - 2) ? '&page='. ($page - 1) : '')), 'prev');
			}

			if ($limit && ceil($product_total / $limit) > $page) {
			    $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1)), 'next');
			}

			$data['sort'] = $sort;
			$data['order'] = $order;
			$data['limit'] = $limit;

			$data['continue'] = $this->url->link('common/home');

			$data['column_left'] = $this->load->controller('common/column_left');
			$data['column_right'] = $this->load->controller('common/column_right');
			$data['content_top'] = $this->load->controller('common/content_top');
			$data['content_bottom'] = $this->load->controller('common/content_bottom');
			$data['footer'] = $this->load->controller('common/footer');

				if( class_exists( 'Mfilter_Helper' ) ) {
					Mfilter_Helper::createMetaLinks( $this, isset( $page ) ? $page : null, isset( $limit ) ? $limit : null, isset( $product_total ) ? $product_total : null );
				}
			
			$data['header'] = $this->load->controller('common/header');
$data['hb_snippets_bc_enable'] = $this->config->get('hb_snippets_bc_enable');


				$this->load->model( 'extension/module/mega_filter' );
				
				$data = $this->model_extension_module_mega_filter->prepareData( $data );
			
			$this->response->setOutput($this->load->view('product/category', $data));
		} else {
			$url = '';

				if( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') ) {
					$url .= '&'.($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp').'=' . urlencode( $this->rgetMFP($this->config->get('mfilter_url_param')?$this->config->get('mfilter_url_param'):'mfp') );
				}
			

			if (isset($this->request->get['path'])) {
				$url .= '&path=' . $this->request->get['path'];
			}

			if (isset($this->request->get['filter'])) {
				$url .= '&filter=' . $this->request->get['filter'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (isset($this->request->get['limit'])) {
				$url .= '&limit=' . $this->request->get['limit'];
			}

			$data['breadcrumbs'][] = array(
				'text' => $this->language->get('text_error'),
				'href' => $this->url->link('product/category', $url)
			);

			$this->document->setTitle($this->language->get('text_error'));

			$data['continue'] = $this->url->link('common/home');

			$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');

			$data['column_left'] = $this->load->controller('common/column_left');
			$data['column_right'] = $this->load->controller('common/column_right');
			$data['content_top'] = $this->load->controller('common/content_top');
			$data['content_bottom'] = $this->load->controller('common/content_bottom');
			$data['footer'] = $this->load->controller('common/footer');

				if( class_exists( 'Mfilter_Helper' ) ) {
					Mfilter_Helper::createMetaLinks( $this, isset( $page ) ? $page : null, isset( $limit ) ? $limit : null, isset( $product_total ) ? $product_total : null );
				}
			
			$data['header'] = $this->load->controller('common/header');
$data['hb_snippets_bc_enable'] = $this->config->get('hb_snippets_bc_enable');


				$this->load->model( 'extension/module/mega_filter' );
				
				$data = $this->model_extension_module_mega_filter->prepareData( $data );
			
			$this->response->setOutput($this->load->view('error/not_found', $data));
		}
	}
}

 

 

только вот что странно, я первый раз делал по основным файлам (с обновлением модификаторов и очищением кеша) а сейчас только модификатор изменил, ошибки нету и каноникала нету

Link to comment
Share on other sites


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

Нельзя страницы постраничной навигации объявлять каноническими.

Честно говоря, я точно знаю, как правильно)))

Чиста из спортивного интереса - где ЭТО написано, что третья страница пагинации не может быть канонической? Вы можете обосновать?

Edited by florapraktik
Link to comment
Share on other sites


6 часов назад, florapraktik сказал:

Честно говоря, я точно знаю, как правильно)))

Чиста из спортивного интереса - где ЭТО написано, что третья страница пагинации не может быть канонической? Вы можете обосновать?

Вот же ссылка, там написано как должно быть.

17 часов назад, Yesvik сказал:

 

 

Или Вам нужно, чтоб чётко было написано «Нельзя ставить каноникал на страницы пагинации!!!»

 

Или покажите ссылку где описано, что можно.

Интересно аж самому теперь стало

Link to comment
Share on other sites

7 часов назад, florapraktik сказал:

Честно говоря, я точно знаю, как правильно)))

Чиста из спортивного интереса - где ЭТО написано, что третья страница пагинации не может быть канонической? Вы можете обосновать?

 

58 минут назад, OCappLab сказал:

Вот же ссылка, там написано как должно быть.

 

 

Или Вам нужно, чтоб чётко было написано «Нельзя ставить каноникал на страницы пагинации!!!»

 

Или покажите ссылку где описано, что можно.

Интересно аж самому теперь стало

 

Да мне нужно сделать по ТЗ которое мне пришло. У меня стоит задача разбираться как сделать правильно в соответствии с правилами гугла) Мне нужно сделать как в ТЗ ))

Link to comment
Share on other sites


Держи модификатор который сделает как ты просил, но ещё раз предупреждаю - в поисковой выдаче гарантировано будет только первая страница категории, с остальными страницами будут приключения.

canonical.ocmod.xml

 

Link to comment
Share on other sites

15 часов назад, florapraktik сказал:

Чиста из спортивного интереса - где ЭТО написано, что третья страница пагинации не может быть канонической? Вы можете обосновать?

Я не правильно выразился. Третья страница может быть канонической, я имел ввиду что лучше не объявлять её канонической в явном виде.

Чуть позже напишу что надо делать чтобы понравилось Гуглу и Яндексу

Link to comment
Share on other sites

Отсутствие атрибута rel="canonical" не означает что страница не каноническая.

Атрибут rel="canonical" нужен для борьбы с дублями, но у Гугла и Яндекса противоречащие рекомендации по применению canonical в постраничной навигации.

Яндекс рекомендует в постраничной навигации объявлять первую страницу канонической, а Гугл считает такое применение canonical ошибочным.

Гугл аргументирует свою рекомендацию тем, что в поисковой выдаче будет только первая страница и это проблема. Яндекс тоже пишет что в поисковой выдаче будет только первая страница и витиевато пудрит мозги.

Если сделать страницу со всеми товарами категории и указывать её как каноническую для всех страниц постраничной навигации - это будет устраивать и Гугл и Яндекс, но не устроит нас. При большом количестве товаров страница будет очень долго грузится и поисковики забракуют её.

Напоминаю - canonical нужен для борьбы с дублями, поэтому надо забить на canonical и сделать каждую страницу уникальной.

Поехали...

1. Описание категории и description выводим только на первой странице категории.

2. Добавляем в title и h1 номер страницы (страница 2, страница 3 и т.д.).

3. Закрываем от поисковиков страницы с изменённым порядком сортировки и количеством товаров на странице.

 

Ссылки по поводу canonical:

Яндекс https://yandex.ru/blog/platon/2878

Обратите внимание на это:

Цитата

советую настраивать атрибут rel="canonical" тега <link> на подобных страницах и делать страницы второй, третьей и дальнейшей нумерации неканоническими, а в качестве канонического (главного) адреса указывать первую страницу каталога, только она будет участвовать в результатах поиска

и читайте комментарии, особенно ответ Платона

Цитата

Вы правы, момент с наличием страницы, на которой собран весь товар раздела, я упустил. Если такая страница присутствует на сайту, действительно, лучше указывать в качестве канонической именно её.

 

Гугл https://webmasters.googleblog.com/2013/04/5-common-mistakes-with-relcanonical.html

посмотрите видео с 14-й минуты

 

  • +1 3
Link to comment
Share on other sites

4 минуты назад, Yesvik сказал:

1. Описание категории и description выводим только на первой странице категории.

 

Есть вопрос по описанию, только на первой странице. На сколько это актуально для магазина, который ни коим боком не новостной портал, где за такое одинаковое описание на каждой странице, можно от ПС получить по шее? А что если я попал в категорию тем или иным способом минуя первую страницу ,не увижу этого самого текста? Да и на сколько вообще актуально наличие или отсутствие описания для категорий в магазине ? Я к примеру ни разу в жизни не прочёл ни единого подобного описания категориии. Как правило там из пальца высосаный текст , который мне как покупателю ничем не поможет. Да и по сути я же пришёл купить, а не почитать . Почитать про товары я хожу на иные ресурсы.

 

По остальным пунктам взял на заметку.... Но и здесь есть момент. То есть каноникал перекрывает проблему дублей, а зачем тогда все эти заморочки с чпу и сеопро?

Пишу не ради споров , а реально понять для себя эту ситуацию.

 

PS : за сообщение плюсанул от души.

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.