News:

Looking for documentation? Take a look on our wiki

Main Menu

Link to the parent product

Started by Wtor22, November 13, 2021, 23:16:38 PM

Previous topic - Next topic

Wtor22

Hello.
There was a need to create a link to the parent product on the child product page.
I really hope for help

hazael

Old topic, but let me write back:

if product is parent, change "virtuemart_product_id" to "product_parent_id"

Jumbo!

You can use the following codes on the product details page.

<?php
if (!empty($this->product->product_parent_id))
{
$model         VmModel::getModel('product');
$parentProduct $model->getProduct($this->product->product_parent_idtruetruetrue1);

if ($parentProduct->virtuemart_product_id 0)
{
echo 'Go back to Parent Product: <a href="' JRoute::_($parentProduct->link) . '">' $parentProduct->product_name '</a>';
}
}
?>