News:

Support the VirtueMart project and become a member

Main Menu

Virtuemart Product customfieldsSorted is empty

Started by Kuubs, November 18, 2020, 14:23:00 PM

Previous topic - Next topic

Kuubs

Hello,

I have a question regarding the product module, I want to display a product with their custom fields. Unfortunately i run into a problem regarding the custom fields. If I use the following rendersublayout:

<?php echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product,'position' => array('ontop''addtocart'))); ?>

Only the add to cart button gets rendered. I checked and it is because the customfieldsSorted is empty:

if (!empty($product->customfieldsSorted[$position])) { ...

Can someone help me out?

I get the product the following way:

$productModel = VmModel::getModel('Product');
$product = $productModel->getProduct(2);
$productModel->addImages($product);

Kuubs

Found the solution:

$products = array();

$products[] = $product;

shopFunctionsF::sortLoadProductCustomsStockInd($products,$productModel);

$product = $products[0];