0

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

\vendor\magento\module-catalog\view\frontend\templates\product\image_with_borders.phtml

( Or )

app\design\frontend\Magento\{custom-theme}\Magento_Catalog\templates\product\image_with_borders.phtml

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

Thank you ,

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

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

<?php
    $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 } ?>
| improve this answer | |
  • your code i already try to this method but not working on category listing page . – udhayakumar 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? – Dhiren Vasoya 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 . – udhayakumar 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. – Dhiren Vasoya 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 . – udhayakumar 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.