Magento – How to add the images for associated bundle product in the cart

bundled-productcart

The options data gets called in the checkout/cart/default.phtml and I believe it's this function:

<?php echo $_formatedOptionValue['value'] ?>

.. that produces looped data for each associated item. How can I show the images for the associated bundle items? Let me know if I am not clear.

Best Answer

To display all images for all products selected in the bundle, you'll have to load up the bundle option selections themselves and send to the thumbnail creation helper.

Warning: Don't edit theme files directly. Copy to your own theme:

app/design/frontend/base/default/template/checkout/cart/item/default.phtml:

Replace this block:

<?php if ($_options = $this->getOptionList()):?>

With this block:

<ul class="bundle-selection">
    <?php foreach($_item->getQuote()->getAllItems()->filterByParent($_item->getId()) as $_selection): ?>
    <li class="bundle-selection">
        <span class="product-thumbnail">
        <img src="<?php echo $this->helper('catalog/image')->init($_selection, 'thumbnail');?>"/></span> <span class="product-name"><?php echo $_selection->getName(); ?></span>
    </li>
    <?php endforeach; ?>
</ul>
<?php if ($_options = $this->getOptionList()):?>
Related Topic