title: How to Add Custom Attribute on product Grid in magento 1.9.2 community edition
body: <p>I am having an issue while showing my custom attribute as column in grid.</p>
  
  <p>First I created an attribute programmatically using update script, here is the code : </p>
  
  <pre><code>$installer = $this;
  
  $installer-&gt;startSetup();
  
  // Set data:
  $attributeName  = 'Owners'; // Name of the attribute
  $attributeCode  = 'owners'; // Code of the attribute
  $attributeGroup = 'General';          // Group to add the attribute to
  $attributeSetIds = array(4);          // Array with attribute set ID's to add this attribute to. (ID:4 is the Default Attribute Set)
  
  // Configuration:
  $data = array(
  'type'      =&gt; 'varchar',       // Attribute type
  'input'     =&gt; 'text',          // Input type
  'global'    =&gt; Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,    // Attribute scope
  'required'  =&gt; false,           // Is this attribute required?
  'user_defined' =&gt; false,
  'searchable' =&gt; false,
  'filterable' =&gt; false,
  'comparable' =&gt; false,
  'visible_on_front' =&gt; false,
  'unique' =&gt; false,
  'used_in_product_listing' =&gt; true,
  'default_value_yesno' =&gt; '0',
  // Filled from above:
  'label' =&gt; $attributeName
  );
  
  // Create attribute:
  // We create a new installer class here so we can also use this snippet in a non-EAV setup script.
  $installer = Mage::getResourceModel('catalog/setup', 'catalog_setup'); 
  
  $installer-&gt;addAttribute('catalog_product', $attributeCode, $data);
  
  
  $installer-&gt;addAttributeToSet(
  'catalog_product', 'Default', $attributeGroup, $attributeCode
  ); //Default = attribute set, General = attribute group
  
  
  
  $installer-&gt;endSetup();
  </code></pre>
  
  <p>This code is working fine for me and it is creating an attribute.</p>
  
  <p>Than I override the grid.php successfully and put my code their but it is not working column is visible in grid but data is not coming.</p>
  
  <p>code of grid.php</p>
  
  <pre><code>public function __construct()
  {
      parent::__construct();
      $this-&gt;setId('productGrid');
      $this-&gt;setDefaultSort('entity_id');
      $this-&gt;setDefaultDir('DESC');
      $this-&gt;setSaveParametersInSession(true);
      $this-&gt;setUseAjax(true);
      $this-&gt;setVarNameFilter('product_filter');
  
  }
  
  protected function _getStore()
  {
      $storeId = (int) $this-&gt;getRequest()-&gt;getParam('store', 0);
      return Mage::app()-&gt;getStore($storeId);
  }
  
  protected function _prepareCollection()
  {
      $store = $this-&gt;_getStore();
      $collection = Mage::getModel('catalog/product')-&gt;getCollection()
          -&gt;addAttributeToSelect('sku')
          -&gt;addAttributeToSelect('name')
          -&gt;addAttributeToSelect('attribute_set_id')
          -&gt;addAttributeToSelect('type_id')
          -&gt;addAttributeToSelect('owners');
  
      if (Mage::helper('catalog')-&gt;isModuleEnabled('Mage_CatalogInventory')) {
          $collection-&gt;joinField('qty',
              'cataloginventory/stock_item',
              'qty',
              'product_id=entity_id',
              '{{table}}.stock_id=1',
              'left');
      }
      if ($store-&gt;getId()) {
          //$collection-&gt;setStoreId($store-&gt;getId());
          $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
          $collection-&gt;addStoreFilter($store);
          $collection-&gt;joinAttribute(
              'name',
              'catalog_product/name',
              'entity_id',
              null,
              'inner',
              $adminStore
          );
          $collection-&gt;joinAttribute(
              'custom_name',
              'catalog_product/name',
              'entity_id',
              null,
              'inner',
              $store-&gt;getId()
          );
          $collection-&gt;joinAttribute(
              'status',
              'catalog_product/status',
              'entity_id',
              null,
              'inner',
              $store-&gt;getId()
          );
          $collection-&gt;joinAttribute(
              'visibility',
              'catalog_product/visibility',
              'entity_id',
              null,
              'inner',
              $store-&gt;getId()
          );
          $collection-&gt;joinAttribute(
              'price',
              'catalog_product/price',
              'entity_id',
              null,
              'left',
              $store-&gt;getId()
          );
      }
      else {
          $collection-&gt;addAttributeToSelect('price');
          $collection-&gt;joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
          $collection-&gt;joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
      }
  
      $this-&gt;setCollection($collection);
  
      parent::_prepareCollection();
      $this-&gt;getCollection()-&gt;addWebsiteNamesToResult();
      return $this;
  }
  
  protected function _addColumnFilterToCollection($column)
  {
      if ($this-&gt;getCollection()) {
          if ($column-&gt;getId() == 'websites') {
              $this-&gt;getCollection()-&gt;joinField('websites',
                  'catalog/product_website',
                  'website_id',
                  'product_id=entity_id',
                  null,
                  'left');
          }
      }
      return parent::_addColumnFilterToCollection($column);
  }
  
  protected function _prepareColumns()
  {
      $this-&gt;addColumn('entity_id',
          array(
              'header'=&gt; Mage::helper('catalog')-&gt;__('ID'),
              'width' =&gt; '50px',
              'type'  =&gt; 'number',
              'index' =&gt; 'entity_id',
      ));
      $this-&gt;addColumn('name',
          array(
              'header'=&gt; Mage::helper('catalog')-&gt;__('Name'),
              'index' =&gt; 'name',
      ));
  
      $store = $this-&gt;_getStore();
      if ($store-&gt;getId()) {
          $this-&gt;addColumn('custom_name',
              array(
                  'header'=&gt; Mage::helper('catalog')-&gt;__('Name in %s', $store-&gt;getName()),
                  'index' =&gt; 'custom_name',
          ));
      }
  
      $this-&gt;addColumn('type',
          array(
              'header'=&gt; Mage::helper('catalog')-&gt;__('Type'),
              'width' =&gt; '60px',
              'index' =&gt; 'type_id',
              'type'  =&gt; 'options',
              'options' =&gt; Mage::getSingleton('catalog/product_type')-&gt;getOptionArray(),
      ));
  
      $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
          -&gt;setEntityTypeFilter(Mage::getModel('catalog/product')-&gt;getResource()-&gt;getTypeId())
          -&gt;load()
          -&gt;toOptionHash();
  
      $this-&gt;addColumn('set_name',
          array(
              'header'=&gt; Mage::helper('catalog')-&gt;__('Attrib. Set Name'),
              'width' =&gt; '100px',
              'index' =&gt; 'attribute_set_id',
              'type'  =&gt; 'options',
              'options' =&gt; $sets,
      ));
  
      $this-&gt;addColumn('sku',
          array(
              'header'=&gt; Mage::helper('catalog')-&gt;__('SKU'),
              'width' =&gt; '80px',
              'index' =&gt; 'sku',
      ));
  
      $store = $this-&gt;_getStore();
      $this-&gt;addColumn('price',
          array(
              'header'=&gt; Mage::helper('catalog')-&gt;__('Price'),
              'type'  =&gt; 'price',
              'currency_code' =&gt; $store-&gt;getBaseCurrency()-&gt;getCode(),
              'index' =&gt; 'price',
      ));
  
      if (Mage::helper('catalog')-&gt;isModuleEnabled('Mage_CatalogInventory')) {
          $this-&gt;addColumn('qty',
              array(
                  'header'=&gt; Mage::helper('catalog')-&gt;__('Qty'),
                  'width' =&gt; '100px',
                  'type'  =&gt; 'number',
                  'index' =&gt; 'qty',
          ));
      }
  
      $this-&gt;addColumn('visibility',
          array(
              'header'=&gt; Mage::helper('catalog')-&gt;__('Visibility'),
              'width' =&gt; '70px',
              'index' =&gt; 'visibility',
              'type'  =&gt; 'options',
              'options' =&gt; Mage::getModel('catalog/product_visibility')-&gt;getOptionArray(),
      ));
  
      $this-&gt;addColumn('status',
          array(
              'header'=&gt; Mage::helper('catalog')-&gt;__('Status'),
              'width' =&gt; '70px',
              'index' =&gt; 'status',
              'type'  =&gt; 'options',
              'options' =&gt; Mage::getSingleton('catalog/product_status')-&gt;getOptionArray(),
      ));
  
      $this-&gt;addColumn('owners',
          array(
              'header'=&gt; Mage::helper('catalog')-&gt;__('Owner'),
              'width'=&gt;'200px',
              'index' =&gt; 'owners',
          ));
      return parent::_prepareColumns();
  
      if (!Mage::app()-&gt;isSingleStoreMode()) {
          $this-&gt;addColumn('websites',
              array(
                  'header'=&gt; Mage::helper('catalog')-&gt;__('Websites'),
                  'width' =&gt; '100px',
                  'sortable'  =&gt; false,
                  'index'     =&gt; 'websites',
                  'type'      =&gt; 'options',
                  'options'   =&gt; Mage::getModel('core/website')-&gt;getCollection()-&gt;toOptionHash(),
          ));
      }
  
      $this-&gt;addColumn('action',
          array(
              'header'    =&gt; Mage::helper('catalog')-&gt;__('Action'),
              'width'     =&gt; '50px',
              'type'      =&gt; 'action',
              'getter'     =&gt; 'getId',
              'actions'   =&gt; array(
                  array(
                      'caption' =&gt; Mage::helper('catalog')-&gt;__('Edit'),
                      'url'     =&gt; array(
                          'base'=&gt;'*/*/edit',
                          'params'=&gt;array('store'=&gt;$this-&gt;getRequest()-&gt;getParam('store'))
                      ),
                      'field'   =&gt; 'id'
                  )
              ),
              'filter'    =&gt; false,
              'sortable'  =&gt; false,
              'index'     =&gt; 'stores',
      ));
  
      if (Mage::helper('catalog')-&gt;isModuleEnabled('Mage_Rss')) {
          $this-&gt;addRssList('rss/catalog/notifystock', Mage::helper('catalog')-&gt;__('Notify Low Stock RSS'));
      }
  
      return parent::_prepareColumns();
  }
  
  protected function _prepareMassaction()
  {
      $this-&gt;setMassactionIdField('entity_id');
      $this-&gt;getMassactionBlock()-&gt;setFormFieldName('product');
  
      $this-&gt;getMassactionBlock()-&gt;addItem('delete', array(
           'label'=&gt; Mage::helper('catalog')-&gt;__('Delete'),
           'url'  =&gt; $this-&gt;getUrl('*/*/massDelete'),
           'confirm' =&gt; Mage::helper('catalog')-&gt;__('Are you sure?')
      ));
  
      $statuses = Mage::getSingleton('catalog/product_status')-&gt;getOptionArray();
  
      array_unshift($statuses, array('label'=&gt;'', 'value'=&gt;''));
      $this-&gt;getMassactionBlock()-&gt;addItem('status', array(
           'label'=&gt; Mage::helper('catalog')-&gt;__('Change status'),
           'url'  =&gt; $this-&gt;getUrl('*/*/massStatus', array('_current'=&gt;true)),
           'additional' =&gt; array(
                  'visibility' =&gt; array(
                       'name' =&gt; 'status',
                       'type' =&gt; 'select',
                       'class' =&gt; 'required-entry',
                       'label' =&gt; Mage::helper('catalog')-&gt;__('Status'),
                       'values' =&gt; $statuses
                   )
           )
      ));
  
      if (Mage::getSingleton('admin/session')-&gt;isAllowed('catalog/update_attributes')){
          $this-&gt;getMassactionBlock()-&gt;addItem('attributes', array(
              'label' =&gt; Mage::helper('catalog')-&gt;__('Update Attributes'),
              'url'   =&gt; $this-&gt;getUrl('*/catalog_product_action_attribute/edit', array('_current'=&gt;true))
          ));
      }
  
      Mage::dispatchEvent('adminhtml_catalog_product_grid_prepare_massaction', array('block' =&gt; $this));
      return $this;
  }
  
  public function getGridUrl()
  {
      return $this-&gt;getUrl('*/*/grid', array('_current'=&gt;true));
  }
  
  public function getRowUrl($row)
  {
      return $this-&gt;getUrl('*/*/edit', array(
          'store'=&gt;$this-&gt;getRequest()-&gt;getParam('store'),
          'id'=&gt;$row-&gt;getId())
      );
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/zBMTL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zBMTL.png" alt="enter image description here"></a></p>