-
Programmatically create invoice of an order in magento
Programmatically create invoice of an order in magento and create partial invoice of an order For some time need to create invoice of an order.I have write code for how to create invoice of an order pragmatically here. First of load an order by order id/order increment id, Check which items of that order are available for create invoice. if ,invoice is not created then create invoice of those items #this code is suite if order does have any invoice $order=Mage::getModel('sales/order')->load($orderID); #checkout order capable to create invoice if($order->canInvoice() and $order->getIncrementId()) { $items = array(); foreach ($order->getAllItems() as $item) { $items[$item->getId()] = $item->getQtyOrdered(); } $invoiceId=Mage::getModel('sales/order_invoice_api')->create($order->getIncrementId(),$items,null,false,true); #capture the invoice Mage::getModel('sales/order_invoice_api')->capture($invoiceId); …
-
Magento custom collection filter and sort
Magento custom collection filter and sort We have already know how to filter magento product ,customer,wishlist,order collection fields filters. But whenever we are working on non-exiting model collection, then we facing problem.Here i have put some tricks how you can filter a custom collection by a field.In post,i have working on a writing how a custom collection is filter by a filed and how the collection will filter. Suppose a custom collection is #Mage::getModel('[ModulePrefix/Entities]')->getCollection(); $collection=Mage::getModel('[custommodule/customemodule]')->getCollection(); For add addFieldToSelect('*') at that Collection for retrieves all field value for a module is Then want to filter that collection by a field name ‘age’ then use $collection->addFieldToSelect('age'); For add for sort by a…