megwoo
6/24/2015 - 5:16 AM

Magento Add Attribute to Product Listing


For search results, add "image" to catalogsearch.xml:

<block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml">
                	<action method="addAttribute"><attribute>image</attribute></action></block>  
     

For product listing, add "image" to catalog.xml:

<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
                	<action method="addAttribute"><attribute>image</attribute></action></block>


Reference image in catalog >> product >> list.phtml:

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(200,null); ?>" width="200" height="200" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'image'), null, true) ?>" />