In this post I am going to explain how to get product cover image by Product Id in PrestaShop 1.7.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // Your Product Id $id_product = 10; // Language id $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); // Get cover image for your product $image = Image::getCover($id_product); // Load Product Object $product = new Product($id_product); // Initialize the link object $link = new Link; $imagePath = $link->getImageLink($product->link_rewrite[Context::getContext()->language->id], $image['id_image'], 'home_default'); echo $imagePath; |
Write an article about ecommerce that help people to grow their ecommerce business. You’ll find best ecommerce guide, news, tips & more!
June 9, 2020 at 4:54 pm
Hello, Sir!
Where do you write this code?
I´m a “new guy” in Prestashop, and I can´t set a cover images for my 4000 products.
Regards.