Magento: 显示所有子库存 Show inventory of simple product of configurable products

//$_product = $this->getProduct()
foreach ($_product->getTypeInstance(true)->getUsedProducts ( null, $_product) as $simple) 
{
 	$stock    = Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple)->getQty();
	$sizename = $simple->getResource()->getAttribute('size')->getFrontend()->getValue($simple);
 	echo $simple->getName()." with size $sizename (".$simple->getSize().") have a stock of $stock";
 	echo '<br/>';
}

来源:http://stackoverflow.com/a/25652768/602382

Leave a Reply