Retrieve product custom media image attribute in magento


If we have create a new media attribute for product, its name is featured_image/

Now we want to call that image attribute. Please check below code


<?php if (($_products = $this->getProductCollection()) && $_products->getSize()):
foreach ($_products->getItems() as $_product):
$_product->load('media_gallery');
echo sprintf('<img src="%s" alt="" />',$this->helper('catalog/image')->init($_product, 'featured_image'));
endforeach;
endif; ?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s