VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: eag on December 12, 2013, 04:09:35 AM

Title: problem to get child product image [SOLVED]
Post by: eag on December 12, 2013, 04:09:35 AM
Hi, this is the scenario.

all childs products with image, parent product no image.

I modify my override template, my-template/html/com_virtuemart/productdetails/default.php
To get the child product list, and build my custom HTML with child product image, add this code:
$model = new VirtueMartModelProduct();
$test = $model->getProductChildIds($this->product->product_parent_id);
$test2 = $model->getProducts($test);
var_dump($test2);


I load product detail page, to a "child 1", and in var_dump I can see only file_url and file_url_thumb in "child 1" data, in "child 2" doen's appear.
If I load product detail page, "child 2", in var_dump, only appears file_url and file_url_thumb in "child 2" data.
If I load product detail page, "child 3", in var_dump, only appears file_url and file_url_thumb in "child 3" data.

I tried others functions like this, but not solve the problem:
$model = new VirtueMartModelProduct();
$test = $model->getProductChildIds($this->product->product_parent_id);
    foreach($test as $testproduct){
          $test2 = $model->getProduct($testproduct, false);
          var_dump($test2);
    }


is a bug? any idea to solve it?


Enviroment
Joomla 2.5.15
Virtuemart 2.0.24c
Title: Re: problem to get child product image
Post by: Milbo on December 12, 2013, 10:53:26 AM
You missed to add the medias to your products

$productModel->addImages($products,1);
Title: Re: problem to get child product image
Post by: eag on December 12, 2013, 11:14:15 AM
Thanks Milbo,

this solve the problem.

Is there any place to find this documentation?

Thanks again