I want to use the first and the second image of a product, I'm now able to use the first one. But how can I reach the second image?
Does the $_product->getMediaGallery('images')
exists in Magento 2?
If not how can I reach the same goal?
I tried to use this:
foreach ($product->getMediaGalleryImages() as $product_img) :
echo $product_img;
endforeach;
And i recived the following error "Error filtering template: Warning: Invalid argument supplied for foreach() in /var/www/html/magento2/app/design/frontend/XXX/xxx/Magento_Theme/templates/xxxx.phtml on line 27"
$_product->getMediaGalleryImages();
to get media images in Magento 2 – Jaimin Sutariya Mar 3 '17 at 18:32$product
in your code. Are you loading it using Product factory? – Jaimin Sutariya Mar 6 '17 at 10:48