Check stock availability of a product

Tweet, share & co

tweet fb share g+ share

Tags


Description

code to check stock availability of product

Code

protected function _isAvailable(Mage_Sales_Model_Order_Item $orderItem, $qty)
{
	if ($orderItem->getProductId()) {
		$stockItem = Mage::getModel('catalog/product')
				  ->load($orderItem->getProductId())
				  ->getStockItem();

		if ($stockItem->getIsInStock() && (int)$stockItem->getQty() >= $qty) {
			return true;
		}
	}
	return false;
}

Comments