When developing with Magento I have maintain a library of most used code snippets. These code snippets are very useful when developing theme or custom module since they save your precious time. You can just use this code snippet as it is without making any major change. Here I’m sharing those super useful Magento snippets that I’ve collected over the past year. Enjoy! Check stock availability of product 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; } Display New …
↧