The Mage::getResourceModel('catalog/product_collection') didn't calculate stock for configurable products.

I think, with MySQL, there is a way, to calculate configurable product stock from simple products stock.

  • simple product = 1 cataloginventory_stock_item
  • configurable product = 2 or more cataloginventory_stock_item

Can someone help us to create a SQL query to do this?

  • you need to assign associated products qty to configurable product Jun 11, 2015 at 11:37

1 Answer 1


Try it the magento way,

$product = Mage::getModel('catalog/product')->load(874); // 874 is the product_id of configurable product

$config = Mage::getModel('catalog/product_type_configurable')

$collection = $config->getUsedProductCollection()

$total_qty = 0;
foreach ($collection as $sprod) {
     //$sprod = Mage::getModel('catalog/product')->load($sprod->getId());
     $qty = intval(Mage::getModel('cataloginventory/stock_item')->loadByProduct($sprod)->getQty());
echo $total_qty;
  • Have a look at Mage_CatalogInventory_Model_Stock_Status::addStockStatusToProducts. It would be a magento way of adding the stock item to each product in your collection. Jun 11, 2015 at 11:05

Your Answer

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