我正在关注this answer以显示我的可配置产品的库存,但我收到了错误消息:
唯一的问题只发生在第一个项目,它显示“null”。
有人知道我该如何解决它?
Configurable.php
$simpleproduct = Mage::getModel('catalog/product')->load($productsIndex);
$qty = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($simpleproduct)->getQty();
$info['options'][] = array(
'id' => $value['value_index'],
'label' => $value['label'],
'price' => $configurablePrice,
'oldPrice' => $this->_prepareOldPrice($value['pricing_value'], $value['is_percent']),
'products' => $productsIndex,
'qty' => $qty, // we are sending stock parameter so we can use it latter in drop down field
);