In grouped.phtml, i'd like to show all simple products image (not only thumbnail, small, basic images but also other images)

So my coded looks like

<?php $collection = $this->getProduct()->getMediaGalleryImages();
foreach ($collection as $_image): ?>
<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize(300); ?>" width="300" height="300" alt="<?php echo $this->escapeHtml($_image->getLabel()) ?>" />
<?php endforeach;?>

But these images show "group product images" not "associated products images".

Please help me.

2 Answers 2

if ($_product->getTypeId() == 'grouped'){
    $associatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
    foreach ($associatedProducts as $_item):
            ->init($_item, 'image', NULL)
            ->resize(265, 265));
            ->init($_item, 'image', NULL)
            ->resize(56, 56));
            ->init($_item, 'image', NULL)
            ->resize(600, 600));

Hope it will help. Thanks :)


getImage() function only able to give you base image of a product.

If want to get all images of product then you should to call media gallery.

    $mediaGallery = $product->getMediaGalleryImages();
    /* get Image one by  using loop*/
    foreach ($mediaGallery as $image) {
        echo ($image->getUrl());


faster way to load media images in the product collection, check url: Faster way to load media images in a product collection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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