Magento get thumbnail image url to be displayed on cart

Nirmal Ram picture Nirmal Ram · Feb 27, 2013 · Viewed 18.1k times · Source

I having problem in getting the thumbnail image url for the items on the Magento Cart

Here is my code:

$quote = Mage::getSingleton('checkout/session')->getQuote();
$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item) {
echo $item->getThumbnail();
}

Does anyone know that why does it returns always blank.

Answer

dagfr picture dagfr · Feb 27, 2013
Mage::helper('catalog/image')->init($item->getProduct(), 'thumbnail');

Will do the trick