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

Loading

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.