News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

[SOLVED] Getting parent product SKU (product page)

Started by EvanGR, October 16, 2020, 10:22:57 AM

Previous topic - Next topic

EvanGR

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


AH

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) {
Regards
A

Joomla 4.4.5
php 8.1

EvanGR


AH

Regards
A

Joomla 4.4.5
php 8.1