Magento – Add "is in stock" column in Products Grid Manage in Backend

Here how to add new column to manage “in stock” and “out of stock” products

edit this file:
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php

around line 58 you find:

1
2
3
4
5
6
7
8
9
10
11
$collection = Mage::getModel('catalog/product')->getCollection()
            ->addAttributeToSelect('sku')
            ->addAttributeToSelect('name')
            ->addAttributeToSelect('attribute_set_id')
            ->addAttributeToSelect('type_id')
            ->joinField('qty',
                'cataloginventory/stock_item',
                'qty',
                'product_id=entity_id',
                '{{table}}.stock_id=1',
                'left');

change that with this:

1
2
3
4
5
6
7
8
9
10
11
12
$collection = Mage::getModel('catalog/product')->getCollection()
            ->addAttributeToSelect('sku')
            ->addAttributeToSelect('name')
            ->addAttributeToSelect('attribute_set_id')
            ->addAttributeToSelect('type_id')
            ->joinField('qty',
                'cataloginventory/stock_item',
                'qty',
                'product_id=entity_id',
                '{{table}}.stock_id=1',
                'left')->joinTable( 'cataloginventory/stock_item', 'product_id=entity_id', array("stock_status" => "is_in_stock") )
            ->addAttributeToSelect('stock_status');

now let’s add the new column

go around line 107 and find “protected function _prepareColumns()”
here we have our columns….just add the following one where you like between other two columns:

1
2
3
4
5
6
7
8
$this->addColumn('stock_status',
            array(
                'header'=> 'Availability',
                'width' => '60px',             //this is the column width
                'index' => 'stock_status',
                'type'  => 'options',
                'options' => array('1'=>'In stock','0'=>'Out of stock'),
        ));

i tested it in ver. 1.3.1

hope u need this

bye bye

Comments

Comments are closed.