How to add Product’s short description in the Product Grid
Note:- Firstly disable the cache from Cache Management tab which is in System tab.
there are many steps to create the extension.
Step1:- Create Mywork_AddAttributeOnProductGrid.xml file in app/etc/modules/.
where Mywork is Namespace and AddAttributeOnProductGrid is Modulename.
<?xml version="1.0"?>
<config>
<modules>
<Mywork_AddAttributeOnProductGrid>
<active>true</active>
<codePool>local</codePool>
</Mywork_AddAttributeOnProductGrid>
</modules>
</config>
Note:- 1) If you want to active the extensions then use true otherwise false.
2) there are three code pool (a) local (b) core (c) community
when we create the own extension then we use local code pool.
Step2:- Now create the config.xml file in app/code/local/Mywork/AddAttributeOnProductGrid/etc/config.xml
<config>
<modules>
<Mywork_AddAttributeOnProductGrid>
<version>1.0.0</version>
</Mywork_AddAttributeOnProductGrid>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<catalog_product_grid>Mywork_AddAttributeOnProductGrid_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
</rewrite>
</adminhtml>
</blocks>
<helpers>
<AddAttributeOnProductGrid>
<class>Mywork_AddAttributeOnProductGrid_Helper</class>
</AddAttributeOnProductGrid>
</helpers>
</global>
</config>
Note:- In this file we created version of this module is 1.0.0
Step3:- Now create the Grid.php file in app/code/local/Mywork/AddAttributeOnProductGrid/Block/Adminhtml/Catalog/Product/
In this file we create class name Mywork_AddAttributeOnProductGrid_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid class. which has two functions
(1) setCollection()
(2) _prepareColumns()
<?php
class Mywork_AddAttributeOnProductGrid_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
{
public function setCollection($collection) {
$collection->addAttributeToSelect('short_description');
$this->_collection = $collection;
}
protected function _prepareColumns()
{
$this->addColumnAfter(‘short_description’,
array(
‘header’=> Mage::helper(‘catalog’)->__(‘Short Description’),
‘width’ => ’60px’,
‘index’ => ‘short_description’,
),’sku’);
return parent::_prepareColumns();
}
}
?>
Step3:- Now create the Data.php file which is in the app/code/local/Mywork/AddAttributeOnProductGrid/Helper/Data.php
<?php
class Mywork_AddAttributeOnProductGrid_Helper_Data extends Mage_Core_Helper_Abstract
{
}
?>