Somehow if you are trying to add product attribute as column to category products section then follow the code with explanation I am sure you can be able to get your exact requirement.Suppose you have a product attribute called “type” then you want to show type of each product in grid of manage product section ,so we will discuss on this how can we add that and in which way.It can be done in two ways one is through observer and second is through grid block I mean you can override the block to your custom module and just do you stuff over there.But I can say overriding block is not good practice but easiest way if there is no module overriding this block ever.Then you can use it no problem.But if don’t wanna check if any other has overrides this block or not ,you just want to do your code independently then use magento’s best feature called event observer concept.

add product attribute as column to category products section
add product attribute as column to category products section

First method:

Event Observer:

If you have little bit idea on event observer concept in magento then you can easily understand what I am explaining here.so lets start with event observer way.

One best thing I would like tell you that how to identify which event is suitable for your requirement.This is the simple way I mean just go to mage.php though dir : app/mage.php and search for dispatchEvent function near to line No – 444 and do you log by Mage::log($name); or Mage::log($name,1,’name.log’,true) make sure log is enabled in magento configuration filed and see which event is suitable for your requirement.I am not explaining more on this topic because this is not our topic.Here our topic is different ,so lets come to our point.I have used here two event which is full-filling my requirement .You can do the same if like this concept.

lets come to the first file called config.xml file,which is located in our module by dir :
app/code/local/[NamespaceName]/[ModuleName]/etc/config.xml
e.g: /app/code/local/JRB/Productgrid/etc/config.xml

You know I have declare my model class by “productgrid” in <models></models> tag and used in my event tag.
Now lets see how my method will call if all event describe is captured.

app/code/local/NamespaceName/ModuleName/Observer
e.g: /app/code/local/JRB/Productgrid/Model/Observer.php

Second method:

Overriding Blocks:

Sometimes if you are not getting success on the above methods and you don’t have enough time to research then do this easiest methods and do your work as quick as possible. Lets see how we can do it by overriding blocks and implement on our custom module.

lets come to the first file called config.xml file same as above method,which is located in our module by dir :
app/code/local/[NamespaceName]/[ModuleName]/etc/config.xml
e.g: /app/code/local/JRB/Productgrid/etc/config.xml

In above config.xml file we overrides the adminhtml blocks by our custom module which is located at JRB_Productgrid_Block_Adminhtml_Catalog_Category_Tab_Product and we just have to append the column to list columns available in _prepareColumns so that our column will be visible on the Grid form. Lets see the codes how I have just appended.

app/code/local/[NamespaceName]/[ModuleName]/Block/Adminhtml/Catalog/Category/Tab/Product.php
e.g: /app/code/local/JRB/Productgrid/Block/Adminhtml/Catalog/Category/Tab/Product.php

Hope you enjoyed this “add product attribute as column to category products section” article and I guess you will not forget to share to help others

Thank you

add product attribute as column to category products section
The following two tabs change content below.
Jyotiranjan is one of passionate programmer who has been working in magento since 4 years and in the mean time he has developed enormous amount of modules and customization of sites.He loves to write blogs and travel for long journeying.
Tagged on:                                     

Leave a Reply

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