How to set order status as β€œfull” in magento

how to set the order status as "full" manually.

I use the following code, but it gives an error saying, The order status of 'complete' should not be set manually.

$order = Mage::getModel('sales/order')->loadByIncrementId($order_id); $order->setState(Mage_Sales_Model_Order::STATE_COMPLETE); $order->save(); 
+4
source share
3 answers

I found a solution for myself

 $order = Mage::getModel('sales/order')->loadByIncrementId($order_id); $order->setData('state', "complete"); $order->setStatus("complete"); $history = $order->addStatusHistoryComment('Order was set to Complete by our automation tool.', false); $history->setIsCustomerNotified(false); $order->save(); 
+18
source

well, the actual way to make COMPLETE order state is to create invoice and shipment , after which state state automatically gets COMPLETE state. How:

 //create invoice for the order $invoice = $order->prepareInvoice() ->setTransactionId($order->getId()) ->addComment("Invoice created from cron job.") ->register() ->pay(); $transaction_save = Mage::getModel('core/resource_transaction') ->addObject($invoice) ->addObject($invoice->getOrder()); $transaction_save->save(); //now create shipment //after creation of shipment, the order auto gets status COMPLETE $shipment = $order->prepareShipment(); if( $shipment ) { $shipment->register(); $order->setIsInProcess(true); $transaction_save = Mage::getModel('core/resource_transaction') ->addObject($shipment) ->addObject($shipment->getOrder()) ->save(); } 
+9
source

Set order status programmatically:

http://blog.chapagain.com.np/magento-how-to-change-order-status-programmatically/

 change order status to 'Completed' 
 $orderIncrementId = YOUR_ORDER_INCREMENT_ID; $order = Mage::getModel('sales/order') ->loadByIncrementId($orderIncrementId); $order->setState(Mage_Sales_Model_Order::STATE_COMPLETE,true)->save(); 
-one
source

Source: https://habr.com/ru/post/1501406/


All Articles