Well, that is pretty simple but in case someone will need this, just: $product = Mage::getModel(‘catalog/product’)->load(123); $inStock = Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($product)->getIsInStock();
How to create Magento shipment programmaticaly?
In case someone will need this, it’s quite simple: $order = Mage::getModel(‘sales/order’)->load( 1234 ); $shipment = Mage::getModel(‘sales/service_order’, $order)->prepareShipment(array()); $shipment->register(); $shipment->getOrder()->setCustomerNoteNotify(false); $shipment->getOrder()->setIsInProcess(true); $transactionSave = Mage::getModel(‘core/resource_transaction’)->addObject($shipment)->addObject($shipment->getOrder())->save();
Magento FACT Finder export
Preparing such export is quite easy, so let’s begin with adding new button in products listing: in app/code/core/Mage/Adminhtml/Block/Catalog/Product.php in _prepareLayout() function add such code: $this->_addButton(‘export_fact’, array( ‘label’ => […]
How to sort Magento products by date added as default
Today I had to change Magento default products list sorting to sort by product’s date. In fact we don’t need to sort by date, just by entity_id which […]
How to get Magento categories with full paths
Maybe someone will need it, so here we go with code: echo “<pre>”; $category = Mage::getModel(‘catalog/category’); $tree = $category->getTreeModel(); $tree->load(); $ids = $tree->getCollection()->getAllIds(); $categories = array(); if ($ids) […]