How can I get the link to my product page in opencart 3.0

20 Views Asked by At

I just want to show the product link to my product page externally between div tags.

the code below only gives the link to my website. I am a beginner in this subject please help

{% if products %}
<a href="{{ product.href }}"> {{product.name }}</a>
{% endif %}
2

There are 2 best solutions below

1
websky group On

hi you should add $data['products'] in controller then use this array in view please attach controller and view to help you

1
MY-Dev On

If you need to show your product URL in the page you should first edit your controller to seem like this

$data['products'] = array(
    // some another data
    'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'])
);

and then you can use

{% if products %}
<a href="{{ product.href }}"> {{product.name }}</a>
{% endif %}