Saturday , February 22 2025

Canonical for pagination in Opencart below version 3

Pagination pages may not have canonicals at all by default. To add their automatic generation, open the file /catalog/controller/product/category.php and in it after the line $this->load->model(‘tool/image’); add the following code:

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 ), 'canonical');
        } else {
            $page = 1;
        }

About iryna

I'm Iryna, a web developer from Ukraine with a decade of experience solving complex technical challenges in the world of freelance. Throughout my career, I've worked on everything from troubleshooting server-side issues and optimizing website performance to enhancing user interfaces. On this blog, I share detailed solutions to the technical problems I’ve encountered and methods that have worked best for me. In addition to my technical expertise, I’m also passionate about digital drawing. I hope the tutorials and insights I provide here will help both fellow developers and creatives alike in their own projects.

Check Also

Removing type=’text/javascript’ and type=’text/css’ from Joomla for validator

At first, as a person from the 17th century, I tried stupidly to remove these …

Leave a Reply

Your email address will not be published. Required fields are marked *