We know in Virtuemart we can make child product leaving some of its parameters that will be taken from parent product. We can understand this with an example like:
First we create one Parent product with name Parent and its two child products Child1 and Child2
Now we set some basic attributes of them:
Parent => Price = $100, Manufacturer = ‘xyz’.
Child1 => Price = not set, Manufacturer = not set
Child2 => Price = $250, Manufacturer = ‘abc’
The buyer will finally get to see
Child1 => Price = $100, Manufacturer = ‘xyz’, taken from its parent.
Child2 => Price = $250, Manufacturer = ‘abc’.
Use of functions and return data:
To use the listed function we must have included vmconfig.php and initialized its loadConfig() method, as
then call respective methods after taking instance of product model as
Just enter your email below to subscribe and receive weekly updates about the most interesting similar articles.
Share article viaSignUp Again
$productModel = VmModel::getModel('Product');
now you can simple call any of the method as
$product = $productModel->getProduct ('$virtuemart_product_id');
$productSingle = $productModel->getProductSingle ('$virtuemart_product_id');
getproduct()will return data with attributes of parent product, while
getproductSingle()will not only return data for a single product but it contains the attribute of the same product regardless of it being a child or a parent.
So, from the above cases
getProductSingle(), returns Manufacturer = ”, on the same hand
getProduct(), returns Manufacturer = ‘xyz’.
for Child2: both
getProduct() returns Manufacturer = ‘abc’ as it is directly set onto that product.
There are other differences in return parameters of both of these functions, as you get basePrice and salesPrice using
getProduct()but have to evaluate final price if you use
For any query regarding virtuemart plugins and add-ons you can communicate with us by creating a ticket at: