显示可配置产品库存 - Magento 1.9

时间:2016-01-28 18:34:58

标签: php magento

我正在关注this answer以显示我的可配置产品的库存,但我收到了错误消息:

error-magento

唯一的问题只发生在第一个项目,它显示“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

                );

0 个答案:

没有答案