Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mkdizajn/4234220 to your computer and use it in GitHub Desktop.
Save mkdizajn/4234220 to your computer and use it in GitHub Desktop.
magento, get the quantitiy from configurable product
<?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