Get simple product images to show in grouped product gallery using Magento's MobileShoppe theme

Show your simple images in your grouped product page!
Show your simple images in your grouped product page!

You have grouped products that may or may not have their own images, but you would like to also see the associated simple product's main images in the grouped carousel (gallery), and they should behave like the images normally do. And you are using the MobileShoppe theme. Done.

Open (or copy the base theme's) "mobile.phtml" located in app/design/frontend/default/mobileshoppe/template/catalog/product/view folder.

Immediately AFTER this section:

    foreach ($this->getGalleryImages() as $_image):
        ?>
        <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
    <?php endforeach; ?>

you can add THIS block of code:

    <?php
    if ($_product->getTypeId() == 'grouped'){
        $subProds = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
        foreach ($subProds as $_item):
            $name = $_item->name;
            $image = strval(Mage::helper('catalog/image')->init($_item, 'image', NULL));
            echo '<img src="' . $image . '" alt="' . $name . '" title="' . $name . '" />';
        endforeach;
    }
    ?>

...and ENJOY!

Tags: