News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Get product image by id

Started by Kuubs, April 02, 2020, 15:18:01 PM

Previous topic - Next topic

Kuubs

Hello,

I want. to display the child products images in a certain way. I have this code, but it doesn't get the images attached to the product:


$productModel = VmModel::getModel('Product');
$products = $productModel->getProductChildIds( $product->virtuemart_product_id);

foreach ($products as $key => $value) {

$childprod = $productModel->getProduct($value);

}



But there isn't anything regarind images in this object. Does anyone know ho I get the image of this certain product?

Kuubs

Fixed it.


Needed to add


$productModel->addImages($childprod,1);

beltoforion

hey hubbs can you post your full fixed code?
wanting to learn to create good templates

Kuubs

Quote from: beltoforion on April 02, 2020, 20:02:58 PM
hey hubbs can you post your full fixed code?

Yeah sure:



<?php 

$productModel 
VmModel::getModel('Product');

$products $productModel->getProductChildIds$product->virtuemart_product_id);

foreach (
$products as $key => $value) {

$childprod $productModel->getProduct($value);

$productModel->addImages($childprod,1);

}

?>




Let me know if this works for you!