We have found the way to add the canonical tag on OpenCart website in a easy way…
First we find the catetory.php file from the category folder
catalog/controller/product/category.php file
Find this line:
if ($category_info) {
and add the following lines after that
$can_url=$this->url->link("product/category","path=".$this->request->get[‘path’]); $this->document->addLink($can_url,”canonical”);
Second we find the catalog controllers file
catalog/controllers/common/home.php
Find this line:
$this->document->setDescription($this->config->get(‘config_meta_description’));
and add the above code after that
$can_url=$this->url->link(‘common/home’); $can_url=str_replace(‘index.php?route=common/home’, ”, $can_url); $this->document->addLink($can_url,’canonical’);
The post How to add cononical tag in opencart appeared first on PHP Blog Spot.