Efficient way to get Image Url in magento?

Currently i am using these method

$my_product = Mage::getModel('catalog/product')->load($value['entity_id']); 
$my_product_img = $my_product->getImageUrl();

I need a efficient way to load the image url in magento as the above query uses 2 many space and unused queries.

Already tried

$my_product_img = Mage::getModel('catalog/product_media_config')->getMediaUrl($my_product->getSmallImage());

Without full load of product object you can product image url

$image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($value['entity_id']), 'image', Mage::app()->getStore()->getId());


$my_product_img = Mage::getModel('catalog/product_media_config')->getMediaUrl($image);

You can get the full product URL using this:

$product = Mage::getModel('catalog/product')->load($value['entity_id']);
$image = Mage::helper('catalog/image')->init($product, 'image');

To get the small_image or thumbnail, you can replace image with any of these values.

  • I tried this but it also loads 2 many queries. i need some thing which does not load entire catalog/product model and directly fetches it value. – Arjun Feb 24 '17 at 7:25

Well you can try below code , it may help you

echo Mage::getBaseUrl().'media/catalog/product'. $_product->getImage();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.