Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anunay/7935721 to your computer and use it in GitHub Desktop.
Save anunay/7935721 to your computer and use it in GitHub Desktop.
<?php
$product=Mage::getModel("catalog/product");
$prod=$product->load($_product->getId());
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($prod);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
$total_qty=0;
foreach($col as $sprod){
$sprod=$product->load($sprod->getId());
$qty = intval(Mage::getModel('cataloginventory/stock_item')->loadByProduct($sprod)->getQty());
$total_qty+=$qty;
}
echo $total_qty;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment