Magento Add custom attributes in product grid or listing page

Magento Add custom attributes in product grid or listing page

In this post we will show you Magento Add custom attributes in product grid or listing page, hear for Magento Add custom attributes in product grid or listing page we will give you demo and example for implement.

At times we need to include the New/Custom items ascribes and needs to show this traits on the frontend items posting page. It is simple and can done by utilizing the means given underneath:

Step 1. Explore to app/code/center/Mage/Catalog/Block/Product/List.php, and duplicate this document to app/code/neighborhood/Mage/Catalog/Block/Product/List.php, with the goal that you will be ok for the Magento adaptation overhaul.

Step 2. Look for the addAttribute strategies and Insert the code underneath before the finish of class

 

/** 

* Use this strategy in formats for additional traits 

* 

* @param string $code interior name of trait 

*/ 

open capacity addAttribute($code) 

{ 

$this->_getProductCollection()- >addAttributeToSelect($code); 

return $this; 

} 

Note: This code is as of now included with new forms of Magento, yet in the event that you are utilizing the more established form at that point include the code lump.

Step 3. Explore to the app/plan/frontend/default/your_custom_theme/format/ and open the catalog.xml record or you can discover this document by exploring to the app/outline/frontend/base/default/design/ and open it in your preferred proofreader. Scan for handlers catalog_category_default and catalog_category_layered and include the New/Custom quality code

 

<catalog_category_default> 

<block type="catalog/product_list" name="product_list" template="catalog/item/list.phtml"> 

... 

<action method="addAttribute"><name>custom_attribute_code1</name></action> 

<action method="addAttribute"><name>custom_attribute_code2</name></action> 

... 

</block> 

</catalog_category_default> 

Step 4. Utilize your characteristic in list.phtml page

Presently you can utilize the custom property in your topics list.phtml page similarly as ordinary, by including utilizing the underneath punctuation

 

reverberate $_product->getAttributeCode(); 

reverberate $_product->getData('attribute_code2'); 

reverberate $_product->getAttributeText('attribute_code2'); 

You have done and invigorate your page to see the progressions.

Hope this code and post will helped you for implement Magento Add custom attributes in product grid or listing page. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org

Leave a Comment

Your email address will not be published. Required fields are marked *

3  +    =  11

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US