Need to Image gallery collection load to following path in magento 2.1.6 category listing page ,


( Or )


Anyone please review the question and let me know your suggestions.

Thank you ,

  • you want all product image colletion on category page? Dec 4 '17 at 13:05
  • @DhirenVasoya , Yes i want all products images collection for category pages . Dec 4 '17 at 13:27

Use below code to get all gallery images on product list page:

    $Om = \Magento\Framework\App\ObjectManager::getInstance();
    $product = $Om->create('Magento\Catalog\Model\Product')->load($_product->getId());        
    $images = $product->getMediaGalleryImages();

    foreach($images as $image) { ?>
        <img src="<?php echo $image->getUrl(); ?>">
<?php } ?>
  • your code i already try to this method but not working on category listing page . Dec 4 '17 at 14:00
  • What error you are facing in above code? Can you show how you implement this code on your category page? Dec 5 '17 at 4:12
  • In your code i just past on below path , app\design\frontend\Magento\{custom-theme}\Magento_Catalog\templates\product\image_with_borders.phtml After that i cleared the cache both adminpanel & via ssh and running category page just blanked display . Please check and let me know your suggestions . Dec 5 '17 at 6:02
  • you need to put the code in proper place where you want to access each product data, you need to put this in foreach loop. Dec 5 '17 at 6:24
  • Yes , but i want below path , ` app\design\frontend\Magento\{custom-theme}\Magento_Catalog\t‌​emplates\product\ima‌​ge_with_borders.phtm‌​l` category page list page . Dec 5 '17 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.