could you please help me join the stock inventory resource to my grid.php? I would like to edit my grid in order to filter by availability "is in stock".

Tried adding this code, but without joining the resource it will not work.

    $this->addColumn('inventory_stock_availability ',
                'header' => Mage::helper('catalog')->__('Status'),
                'width' => '100px',
                'index' => 'inventory_stock_availability',
                'type' => 'options',
                'options' => Mage::getSingleton('catalog/inventory_stock_availability ')->getOptionArray(),

my grid file is just like this one https://github.com/jayelkaake/enhancedgrid/blob/master/app/code/community/TBT/Enhancedgrid/Block/Catalog/Product/Grid.php

1 Answer 1


Add below code:

$collection = Mage::getModel('catalog/product')->getCollection()
    )->joinTable('cataloginventory/stock_item', 'product_id=entity_id', array('stock_status' => 'is_in_stock'))

Add below code in function _prepareColumns()

$this->addColumn('stock_status', array(
    'header'=> 'Availability',
    'width' => '60px',
    'index' => 'stock_status',
    'type'  => 'options',
    'options' => array(
        '1' => 'In stock',
        '0' => 'Out of stock'
  • this solution does not work for me: Fatal error: Call to a member function getBackend() on a non-object in app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 816 Apr 5, 2016 at 10:06
  • Update code check it.It is working for me Apr 5, 2016 at 10:12
  • sorry where do you add the first code exactly? what line? thanks! Apr 5, 2016 at 10:13
  • You just need to add code: ->joinTable( 'cataloginventory/stock_item', 'product_id=entity_id', array("stock_status" => "is_in_stock") ) ->addAttributeToSelect('stock_status'); after your collection code in function _prepareCollection Apr 5, 2016 at 10:18
  • ok, that's fine now I see the column, but does it work for you when you filter it? for example by searching only "out of stock" products? for me it does not thanks again Apr 5, 2016 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.