I am trying to get the SKU for the parent product, in a product page.
I do the following in the default.php (product page):
$parentProductId = $product->product_parent_id;
// $parentProductId is now 12434, good so far
$productModel = VmModel::getModel('Product');
$parentProduct = $productModel->getProduct($parentProductId);
print_r($parentProduct);
// this prints nothing
Can anyone spot the problem?
Thanks
There could be a lot of reasons:
You could try:
$parentProduct = $productModel ->getProduct($product->product_parent_id, true, true, false);
See function arguments below:-
Quotepublic function getProduct ($virtuemart_product_id = NULL, $front = TRUE, $withCalc = TRUE, $onlyPublished = TRUE, $quantity = 1,$virtuemart_shoppergroup_ids = 0) {
This worked, thank you very much!
You are welcome :)