Canonical в OpenCart 2x
Один из способов добавить rel=’canonical’ со ссылкой на текущую страницу (именно текущую), да, такие извраты тоже попадаются…
Страница категорий
Правим catalog/controller/product/category.php, в блоке public function index(), после $this->load->model(‘tool/image’); добавляем
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
$pathx = explode('_', $this->request->get['path']);
$pathx = end($pathx);
$this->document->addLink($this->url->link('product/category', 'path=' . $pathx . '&page='. ($page), true), 'canonical');
} else {
$page = 1;
}
Страница производителя
Правим catalog/controller/product/manufacturer.php, в блоке public function index(), после $this->load->model(‘tool/image’); добавляем или правим код, если он есть
if (isset($this->request->get['manufacturer_id'])) {
$page = $this->request->get['page'];
$this->document->addLink($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&page='. ($page), true), 'canonical');
}
Или же второй вариант, в блоке public function info() {, ориентировочно в 97 строке в конструкцию
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
добавляем
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
if (isset($this->request->get['manufacturer_id'])) {
$this->document->addLink($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&page=' .($page)), 'canonical');
}
} else {
$page = 1;
}
Информационная страница
Правим файл catalog/controller/information/information. Так как такие страницы обычно без пагинаций, можно обойтись вставкой кода
if (isset($this->request->get['information_id'])) {$this->document->addLink($this->url->link('information/information', 'information_id=' . $this->request->get['information_id']), 'canonical');}
в блоке public function index() { , после условия объявления хлебных крошек $data[‘breadcrumbs’][] = array( *** );
Стандартная страница контактов (contact-us)
Правим файл catalog/controller/information/contact.php. В блоке public function index() { после объявления массива хлебных крошек добавляем строку
$this->document->addLink($this->url->link('information/contact'), 'canonical');