Opencart Additions to Product and Category


I am using OpenCart 2 and it is very good but I want to add a couple of things to the template and not sure if possible. I have looked for an extension for either of these things and have not been able to find one so if someone can tell me how I can do these things myself or point me towards an extension that will do this for me that will be amazing.

1. On the category pages I want to add a link to the parent category. I know there are breadcrumbs but I need a back link to the parent category of the current category. I would hopefully be able to add this in with a code like <?php echo $parent; ?> into the template and that would display the parent URL

2. On the product page I also need to insert the current products URL (this is for sharing code) can this be done in the template?

Any help and advice will be much appreciated.

Kind Regards
Adam WassallAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Adam WassallAuthor Commented:

None of these extensions are what I am looking for.

For point 1 I have solved myself. I added the code below into \catalog\controller\product\product.php

$data['canonical_links'] = $this->url->link('product/product', 'product_id=' . $this->request->get['product_id']);

Open in new window

And then use <?php echo $canonical_links; ?> in the template to eco the canonical link


For Point 2. I am already using the Full Product Path Extension. And I know that I could use the breadcrumbs but I have a lot of deep categories (4-5 subcategories with some) and only want the link to the direct parent category.

So If the category structure was Category  > Sub-Category  > Sub-Sub-Category

On the  Sub-Sub-Category I want a link to Sub-Category and on Sub-Category a link to Category

Can someone please give me advice on this?
Adam WassallAuthor Commented:
In case anyone else is looking for a solution to this question I have solved the problem myself. It was quite simple actually.

You add this code to catalog/controller/product/category.php
$data['info_parent_url'] = $this->url->link('product/category', 'path=' . $category_info['parent_id']);

Open in new window

then in the category.tpl file you can use <?php echo $info_parent_url; ?>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Adam WassallAuthor Commented:
No one provided me with help on this issue but I have solved it myself. I have included the changes needed to be made that are the solution to my problem.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.