Get base product image in Magento

Dave picture Dave · Aug 16, 2012 · Viewed 63.7k times · Source

I want to get base product image in Magento to resize it and display in cart sidebar.

Unfortunatelly this:

echo $this->helper('catalog/image')->init($_product, 'image')->resize(38, 38);

prints Magento placeholder image.

Base image is set for this product properly. Small image and thumbnail works great.

No idea what's going on.

EDIT: Solution: Get full product data this way:

$_product = Mage::getModel('catalog/product')->load($_item->getProduct()->getId());

and then use it as you wish:

echo $this->helper('catalog/image')->init($_product, 'image')->resize(38, 38);

Answer

pzirkind picture pzirkind · Aug 16, 2012

I think you are looking for this:

echo Mage::getModel('catalog/product_media_config')
        ->getMediaUrl( $product->getImage() ); //getSmallImage(), getThumbnail()

Credit should be given to BenMarks who gave this answer.