In OpenCart, pagination pages are defined through the «page» parameter, even if the SEO URL is enabled in the settings. Therefore, in order to avoid duplicate URLs or similar pages, you should set <link> tag with the attribute «rel =”canonical”» on the pagination pages.
The site already has an article on how to do this on different CMS in PHP.
In this article I want to show how you can make a canonical URL («rel=”canonical”») through the standard OCMOD modification mechanism. Of course, no one forbids doing it directly through the code, but it seems to me that through modifications it is more convenient.
We create the modification file rel_canonical.ocmod.xml, which will be located in the /system/ folder. It is in this file that all changes to the engine will be made.
About the code:
1) In the header controller (catalog/controller/common/header.php) of the site, look for the output of the header template ($this->load->view (‘common/header’, $data);) and insert our code before rendering it .
2) Create the variable $data[‘canonical’], into which we add the canonical URL if the pagination page is opened.
3) We check if the «page» parameter is present in the URL, and if so, and it is more than 1, then we execute the code.
4) $data[‘title’].= ‘| Page ‘.$ _ REQUEST[‘page’]; – this line is optional, if you want to add the page number in the browser title.
5) Next, we get the current URL and remove all parameters from it, so that we get a canonical URL.
6) And finally, in the header template of your template, we determine if the $canonical variable is not empty, display the <link rel =”canonical”> tag.
If you have any questions, want to get individual advice or you have an interesting offer, you can contact via the feedback form.
Or write to the email email@example.com