Sorry, nothing in cart.
Since Magento uses stock information
In Stock and
Out of Stock to show products on a Magento store unless specified otherwise. This default directive prevents it from showing any products that do not have inventory associated with them. This will pose a problem in two specific scenarios i.e.
- Pre-selling products won’t be possible since Magento won’t display out of stock products
- Won’t allow you to back order stocks information
Although, there is a setting in Magento which will allow you to display products even if they are out of stock or doesn’t have an inventory for.
Magento => System => Configuration and then click
Stock Option and then select
Display Out Of Stock Products to
Display Additional Stock Information In Magento
What if you wan to display how many stock quantity are availabe or any other stock related information on your product page? This is simple, just add the following line of code
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
Notice that $stock array contains many useful bits of information which you may or may not need. You can easily print the entire array to see it content by
print_r($stock->getData( ));. Similarly, you can also print each individual data like
echo $stock->getQty(); // Will display stock quantity echo $stock->getMinQty(); // Will display minimum quantity echo $stock->getMinSaleQty(); //will display minimum salable quantity
I hope, this short tutorial will help you play with Magento stock inventory. Please leave us a comment and share your experiences of displaying Magento stock, inventory or other stock information on your Magento storefront.