i just found that the isMsgVisible() do not get the stock by using $this->getStockQty(), the full function are as follow:

public function isMsgVisible()
    return ($this->getStockQty() > 0 && $this->getStockQty() <= $this->getThresholdQty());

The getStockQty()

public function getStockQty()
    if (!$this->hasData('product_stock_qty')) {
        $qty = 0;
        if ($stockItem = $this->_getProduct()->getStockItem()) {

            //$qty = (float) $stockItem->getStockQty();
            $qty = (float) $stockItem->getQty();
        $this->setData('product_stock_qty', $qty);
    return $this->getData('product_stock_qty');

The $stockItem->getStockQty() is always return 0, i have to change to getQty() to make it works. Is it a bug? i'm not dare to patch to production site now.

  • please try this:-$product->getStockItem()->getQty(); Mar 31, 2016 at 5:15

1 Answer 1


Hi check below code may be help you

$_product = Mage::getModel('catalog/product')->load($productId);
$inventory =  Mage::getModel('cataloginventory/stock_item')>loadByProduct($_product);
echo $inventory->getQty();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.