I have been trying to work this out for the past few hours. Hope you guys can help. I am working on a magento website 1.9.0.1 and trying to display the products currently in the cart as a widget elsewhere. I am able to display the Product Name, Price, qty and the grand total. However I can not get the product image to display. Instead of the product image the default magento placeholder image is displayed.
This is the code block that i am working with :
<?php
$quote = Mage::helper('checkout')->getQuote();
foreach ($quote->getItemsCollection() as $item) { ?>
<div class="cart-single">
<div class="cart-content-image">
<img src="<?php echo Mage::helper('catalog/image')->init($item->getProduct(), 'thumbnail')->resize(50, 50); ?>" alt="<?php echo $item->getName(); ?>" />
</div>
<div class="cart-content-details">
<?php
$maxLength = 50;
$productName = $item->getName();
echo '<div class="cart-content-name-short">'.substr($productName, 0, $maxLength).'...</div>';
echo '<div class="cart-content-name-full">'.$item->getName().'</div>';
echo '<div class="cart-content-price">'. $this->helper('checkout')->formatPrice($item->getPrice(), 2).'</div>';
echo '<div class="cart-content-qty">Qty : '. $item->getQty().'</div>';
?>
</div>
</div>
<?php }
?>
The problem I am having is on this line:
<img src="<?php echo Mage::helper('catalog/image')->init($item->getProduct(), 'thumbnail')->resize(50, 50); ?>" alt="<?php echo $item->getName(); ?>" />
I have searched for the past few hours, and tried different solutions, but couldn't get them to work, so I thought I'd display the code in question.
Help and advise appreciated. Thanks