Opencart Get Category URL Based on Category ID

I work with a template in opencart, where I manually create links.

Category links in the storefront can be changed to friendly SEO URLs, so I don’t want to copy URLs that look like index.php?route=product/category&path=100if I have to go back and change it later.

I was wondering if there is some kind of PHP code that I could use to create a link based on the category identifier.

Let's say if my category id 152

I want to be able to use PHP in my own <a href"#">to say something like this:

<a href="<?php get link for category '152' ?>">

Of course, I know that this is not code. But does anyone know a solution? Thanks

+4
source share
1 answer

You just need to use the URL rewrite class, passing it the category identifier

<a href="<?php echo $this->url->link('product/category', 'path=152'); ?>">
+6
source

Source: https://habr.com/ru/post/1529312/


All Articles