TransWikia.com

Magento 2 : How to Load Image Collection in Category Listing Page

Magento Asked by udhayakumar on November 19, 2021

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

vendormagentomodule-catalogviewfrontendtemplatesproductimage_with_borders.phtml

( Or )

appdesignfrontendMagento{custom-theme}Magento_Catalogtemplatesproductimage_with_borders.phtml

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

Thank you ,

One Answer

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

<?php
    $Om = MagentoFrameworkAppObjectManager::getInstance();
    $product = $Om->create('MagentoCatalogModelProduct')->load($_product->getId());        
    $images = $product->getMediaGalleryImages();

    foreach($images as $image) { ?>
        <img src="<?php echo $image->getUrl(); ?>">
<?php } ?>

Answered by Dhiren Vasoya on November 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP