VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: moonaway on November 22, 2014, 13:01:36 PM

Title: How I get product image thumb by produt ID?
Post by: moonaway on November 22, 2014, 13:01:36 PM
Hi!
I make 'Review Module' for VM3 (VM2.6+), but have some trouble with get image of CHILD product who do not have the image (because the image is at the parent product).

Now I use the code:

$product = $productModel->getProductSingle($item->virtuemart_product_id);
$productModel->addImages($product,1);

....then....

echo $product->images[0]->file_url_thumb;

But it's don't work for child products...  If I use 'getProduct' instead of 'getProductSingle' then everything will works, but I want to find a solution which will be better for performance...

Perhaps it is necessary to correct the function "getProductSingle" ??

PS: I'm ready to share the module with all those who help solve the problem
Title: Re: How I get product image thumb by produt ID?
Post by: Milbo on November 24, 2014, 09:32:39 AM
You should just not use getProductSingle, use getProduct.
getProductSingle loads exactly one Product, no Parents and similar.  that means if you load a child with getProductSingle, you get an almost empty Product.