Follow by Email

Wednesday, September 28, 2011

How to get product image in magento

If you have the product collection object like
$collection = Mage::getModel('catalog/product')->getCollection();

Now you can get product sku using $_product->getSku()
if you can't get image path with
echo $this->helper('catalog/image')->init($_product,'small_image')->resize(135);
or $_product->getImageUrl()

then you can add a little code
$model = Mage::getModel('catalog/product');
$prod = $model->loadByAttribute('sku', $_product->getSku());
Now you can get product url with this
$prod->getImageUrl();

3 comments: