I was wondering how we could add a stock value in the 'backend new order creation' ... see image below
What we see now is that we enter an order, but in the next step are warned that ther is no stock ... so why not add the stock value as a column. Also we would very much like to filter on configurable products.
I was looking at app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php
and wanted to add this code
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
$this->addColumn('qty',
array(
'header'=> Mage::helper('catalog')->__('Qty'),
'width' => '30px',
'type' => 'number',
'index' => 'qty',
));
}
and the field itself in collection
protected function _prepareCollection()
{
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
$collection = Mage::getModel('catalog/product')->getCollection();
$collection
->setStore($this->getStore())
->addAttributeToSelect($attributes)
->addAttributeToSelect('sku')
->addStoreFilter()
->addAttributeToFilter('type_id', array_keys(
Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()
))
->addAttributeToSelect('gift_message_available');
Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
$collection->joinField('qty',
'cataloginventory/stock_item',
'qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left');
}
but now the problems is that the 'order quantity' (most right column in image) is also called qty ... and now they are conflicting. Question: How would I get the stock qty as 'alternate name' and show it?
And could we also easily add configurable/simple product selector?