I'm attempting to get Magento to show a Configurable product's stock base in the product grid. Obviously Configurable products don't have a quantity, so I mean I want to modify the way that product quantity is shown by some logic similar to:
if (product != configurable)
{qty = do what it normally does}
else
{get collection of associated products.
qty = sum of qty of that collection;}
I've found several controllers with reference to quantity such as this Block/Catalog/Product/grid.php
protected function _prepareCollection()
{
$collection = $this->getCollection();
if($queryString = $this->getQueryStr()) {
$collection = Mage::Helper('enhancedgrid')
->getSearchCollection($queryString, $this->getRequest());
}
if(!$collection) {
$collection = Mage::getModel('catalog/product')->getCollection();
}
$store = $this->_getStore();
$collection
->joinField('qty',
'cataloginventory/stock_item',
'qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left');
$collection->addAttributeToSelect('sku');
But I haven't been able to get anywhere on it.
If none of this is possibly - just adding the 'Stock Availability' result would suffice.
Edit: ^This won't work as the configurable products are "IN STOCK" but all associated products are "OUT OF STOCK"
Thanks