Magento Get Product Availability by Product Id


Magento Get Product Availability by Product Id : Mage::getModel(‘cataloginventory/stock_item’) is used to get the product availability in magento. You can load catalog inventory stock item by product object. Here in this tutorial we are going to explain how to get Product is in stock or not.


Magento Get Product Availability by Product Id

First load the product by product id then use product object to check whether the item is in stock or not. Here is syntax to check the stock availability of the product.

Magento Check Product is in stock or out of stock

Magento Check Product is in stock by Product Id


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

Where $productId is product’s id which you want to check whether it is available or not. $stocklevel will give you the level of availability.


Add Comment

📖 Read More


Advertisements