{"id":7510,"date":"2019-10-11T08:22:47","date_gmt":"2019-10-11T02:52:47","guid":{"rendered":"https:\/\/www.hiddentechies.com\/blog\/?p=7510"},"modified":"2020-10-09T18:43:27","modified_gmt":"2020-10-09T13:13:27","slug":"get-all-images-of-product-by-product-id-in-prestashop","status":"publish","type":"post","link":"https:\/\/www.hiddentechies.com\/blog\/prestashop\/get-all-images-of-product-by-product-id-in-prestashop\/","title":{"rendered":"How to get all images of product by Product Id in PrestaShop 1.7"},"content":{"rendered":"<p>In this post I am going to explain how to get all images of product by Product Id in PrestaShop 1.7.<\/p>\n<pre class=\"lang:default decode:true \">\/\/ Your Product Id\r\n$id_product = 10;\r\n\r\n\/\/ Language id\r\n$id_lang = (int) Configuration::get('PS_LANG_DEFAULT');\r\n\r\n\/\/ Load Product Object\r\n$product = new Product($id_product);\r\n\r\n\/\/ Validate CMS Page object\r\nif (Validate::isLoadedObject($product)) {\r\n\t\/\/ Get product images\r\n\t$productImages = $product-&gt;getImages((int) $id_lang);\r\n\r\n\tif ($productImages &amp;&amp; count($productImages) &gt; 0) {\r\n\r\n\t\t\/\/ Initialize the link object\r\n\t\t$link = new Link;\r\n\r\n\t\tforeach ($productImages AS $key =&gt; $val) {\r\n\t\t\t\/\/ get image id\r\n\t\t\t$id_image = $val['id_image'];\r\n\r\n\t\t\t\/\/ If required check image is cover or not\r\n\t\t\t$cover = $val['cover'];\r\n\r\n\t\t\t\/\/ Create image path using link object\r\n\t\t\t$imagePath = $link-&gt;getImageLink($product-&gt;link_rewrite[Context::getContext()-&gt;language-&gt;id], $id_image, 'home_default');\r\n\r\n\t\t\techo $imagePath . \"&lt;br&gt;\";\r\n\t\t}\r\n\r\n\t\t\/\/ Print Product Images Array If Required\r\n\t\techo \"&lt;pre&gt;\";\r\n\t\tprint_r($productImages);\r\n\t\texit;\r\n\t}\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<div class=\"angwp_12010 _ning_cont _ning_hidden _ning_outer _align_center responsive\" data-size=\"custom\" data-bid=\"12010\" data-aid=\"0\" style=\"max-width:800px; width:100%;height:inherit;\"><div class=\"_ning_label _left\" style=\"\"><\/div><div class=\"_ning_inner\" style=\"\"><a href=\"https:\/\/www.hiddentechies.com\/blog?_dnlink=12010&t=1779102522\" class=\"strack_cli _ning_link\" target=\"_blank\">&nbsp;<\/a><div class=\"_ning_elmt\"><img decoding=\"async\" src=\"https:\/\/www.hiddentechies.com\/blog\/wp-content\/uploads\/angwp\/items\/12010\/Banner-2.png\" \/><\/div><\/div><\/div><div class=\"clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>In this post I am going to explain how to get all images of product by Product Id in PrestaShop 1.7. \/\/ Your Product Id $id_product = 10; \/\/ Language id $id_lang = (int) Configuration::get(&#8216;PS_LANG_DEFAULT&#8217;); \/\/ Load Product Object $product = new Product($id_product); \/\/ Validate CMS Page object if (Validate::isLoadedObject($product)) { \/\/ Get product images&#8230; <\/p>\n<div class=\"actions\"><a href=\"https:\/\/www.hiddentechies.com\/blog\/prestashop\/get-all-images-of-product-by-product-id-in-prestashop\/\">Continue Reading<\/a><\/div>\n","protected":false},"author":1,"featured_media":7530,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[221,222,2139],"tags":[629,313,329,331],"_links":{"self":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/7510"}],"collection":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/comments?post=7510"}],"version-history":[{"count":1,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/7510\/revisions"}],"predecessor-version":[{"id":7511,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/7510\/revisions\/7511"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media\/7530"}],"wp:attachment":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media?parent=7510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/categories?post=7510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/tags?post=7510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}