In my prestashop module i have to display product with image. I have my variable products which contain all products data, but id_image not contain the real id of the image of the product but a string which is : "fr_default"
I found where this string is send with the following stackoverflow topic : Product::getProductsProperties(): 'id_image' returns 'en_default', not image
But there's no solution, I always have the '?' and the url image is not working.
I'm on Prestashop 1.6.0.6 and i write my products variable with those line :
$products_partial = Product::getProducts($context->language->id, 0, 40, 'name', 'asc');
$products = Product::getProductsProperties($context->language->id, $products_partial);
I developed a module in which I use this line to retrieve the images and links :
$products_partial = Product::getProducts($context->language->id, 0, 40, 'name', 'asc');
$products = Product::getProductsProperties($context->language->id, $products_partial);
foreach ($products as $key => $product) {
$cover = Product::getCover($product['id_product']);
$products[$key]["id_image"] = $cover["id_image"];
}
I hope this can help you.
I use the same code, but I cannot display images.
Do you have an idea of the issues? thanks
public function initContent()
{
parent::initContent();
$products_partial = Product::getProducts($this->context->language->id, 0, 0, 'name', 'asc');
$products = Product::getProductsProperties($this->context->language->id, $products_partial);
$this->context->smarty->assign(array(
'products' => $products,
'homeSize' => Image::getSize('home_default')
));
foreach ($products as $key => $product) {
$cover = Product::getCover($product['id_product']);
$products[$key]["id_image"] = $cover["id_image"];
}
$this->setTemplate(_PS_THEME_DIR_.'catalogue.tpl');
}