I'm trying to modify the Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid (where products are searched for in Magento Admin Order Create) in an attempt to add some custom inventory fields.
The inventory is stored as a product attribute against each individual product dependant on a warehouse location. The available locations are then defined in the config and called to fetch all locations and display stock. Below is the code I have in the grid.php
$warehouseCodes = Mage::getStoreConfig('salesman/general/warehouse_code');
$warehouses = explode(',',$warehouseCodes);
foreach ($warehouses as $warehouse) {
$this->addColumn($warehouse . "_stock", array(
'header'=> Mage::helper('catalog')->__($warehouse . " Stock"),
'width' => '30px',
'type' => 'number',
'index' => Mage::helper('catalog')->__($warehouse . "_stock"),
));
}
The good news is that the code works, however the stock figures do not show up against the products until the column is sorted in the grid. Whereas adding a column explicitly rather than using variables works as expected (code below).
$this->addColumn('far_stock', array(
'header'=> Mage::helper('catalog')->__('Far Stock'),
'width' => '30px',
'type' => 'number',
'index' => 'far_stock',
));