In VirtueMartModelProduct class there are two methods to get a product object from the database: getProductSingle()
and getProduct()
. I'm a bit confused with the code below each method, so I would like to know what's the difference between them and when I have to use getProductSingle
instead of getProduct
.
The VirtueMartModelProduct class is at: administrator\components\com_virtuemart\models\product.php
I know its a bit late, but you can understand it with this. As the documentation of Virtuemart says
getProduct()
function creates a product with the attributes of the parent.
We know in Virtuemart we can make child products leaving some of its parameters that will be taken from parent product. So we set product
Parent Price = $100, Manufacturer = 'xyz'.
Now if two child products are created like:
Child1 is created with blank Price and Manufacturer
Child2 is created with its own values 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:
for Child1: getProductSingle()
, returns Manufacturer = '', on the same hand getProduct()
, returns Manufacturer = 'xyz'.
for Child2: both getProductSingle()
and getProduct()
returns Manufacturer = 'abc' as it is directly set onto that product.
There are other difference in parameters, as you get
salesPrice
usinggetProduct()
but have to calculate final price if you usegetProductSingle()