Magento – Magento 1 – How to get a products small image in the side cart

cartimagemagento-1.7

I used this code to display a Thumbnail image :

<?php echo $this->getProductThumbnail()->resize(50, 50)?>

but i would like to display the small image. I used that to my sidebar cart

Best Answer

You can use the catalog image helper to get any type of image.

$_product = $_item->getProduct();
echo Mage::helper('catalog/image')->init($_product, 'small_image')->resize(50,50);

If I'm correct $_item->getProduct() is an instance of Mage_Catalog_Model_Product, if not you'll need to load the instance first per item

$_product = Mage::getModel('catalog/product')->load($_item->getProduct()->getId());
echo Mage::helper('catalog/image')->init($_product, 'small_image')->resize(50,50);
Related Topic