VirtueMart 2 + 3 > Product creation

Link to the parent product

(1/1)

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.


--- Code: ---<?php
if (!empty($this->product->product_parent_id))
{
$model         = VmModel::getModel('product');
$parentProduct = $model->getProduct($this->product->product_parent_id, true, true, true, 1);

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

Navigation

[0] Message Index

Go to full version