In this post I am going to explain how to get all images of product 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 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | // Your Product Id $id_product = 10; // Language id $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); // Load Product Object $product = new Product($id_product); // Validate CMS Page object if (Validate::isLoadedObject($product)) { // Get product images $productImages = $product->getImages((int) $id_lang); if ($productImages && count($productImages) > 0) { // Initialize the link object $link = new Link; foreach ($productImages AS $key => $val) { // get image id $id_image = $val['id_image']; // If required check image is cover or not $cover = $val['cover']; // Create image path using link object $imagePath = $link->getImageLink($product->link_rewrite[Context::getContext()->language->id], $id_image, 'home_default'); echo $imagePath . "<br>"; } // Print Product Images Array If Required echo "<pre>"; print_r($productImages); exit; } } |
Write an article about ecommerce that help people to grow their ecommerce business. You’ll find best ecommerce guide, news, tips & more!
Leave a Reply