Forked from mkdizajn/magento, get the quantitiy from configurable product
Last active
December 31, 2015 04:39
-
-
Save anunay/7935721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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