Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get base product image in Magento

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);
like image 429
Dave Avatar asked Aug 16 '12 20:08

Dave


1 Answers

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.

like image 196
pzirkind Avatar answered Nov 12 '22 06:11

pzirkind