Skip to content

Instantly share code, notes, and snippets.

@ksysctl
Created April 9, 2013 22:17
Show Gist options
  • Select an option

  • Save ksysctl/5349925 to your computer and use it in GitHub Desktop.

Select an option

Save ksysctl/5349925 to your computer and use it in GitHub Desktop.
Get quantity for every simple product that build a configurable product in Magento
<?php
// $_product = $this->getProduct();
$stock = 0;
$simpleProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $_product);
foreach ($simpleProducts as $simple) {
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple);
if ($stockItem->getIsInStock()) {
$qty = intval($stockItem->getQty());
$stock += $qty;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment