Is it possible to get product availability by passing a product ID to the Magento system?
To fetch the quantity (in stock) for any given product
$model = Mage::getModel('catalog/product');
$_product = $model->load($product_id);
$stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
->loadByProduct($_product)->getQty();
You can get stock info (Mage_CatalogInventory_Model_Stock_Item
class) by product's ID without loading whole product data (at least in Magento 1.7)
$stockItem = Mage::getModel('cataloginventory/stock_item')
->loadByProduct($productId);
And then you can use getQty()
and other methods on $stockItem
object to get required info. You can find them in the source file for the class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With