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

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


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');
			}

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

 

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

 

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.