I want to change order status from pending to processing in Magento 1.9, how can I do this?
3 Answers
The states like "pending" and "processing" change based on certain conditions. You can define custom statuses but those are always assigned to one of those states.
To get from "pending" from "processing", create an invoice or a shipment. Orders become "processing" if one of these exist but not both.
Update: I see, you tagged the post with php. Programmatically, you can change the state like this:
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
Note that there are some guards in place before the order is saved. You cannot change from any to any state, but from pending to processing it's always possible.
-
can you please share the file location where i can update this code Commented Jun 14, 2017 at 12:02
-
No because I have no idea where you want to do it. Commented Jun 14, 2017 at 12:33
I am not sure what consequences it may have but I managed to change the "State" and "Status" of the order directly in the database using following query:
UPDATE `sales_flat_order` SET `state` = 'processing', `status` = 'processing' WHERE `sales_flat_order`.`increment_id` = [your order];
If you want to change it programatically, you can use this code
$orderId = YOUR_ORDER_ID;
$order = Mage::getModel('sales/order')->load($orderId);
$orderIncrementId = YOUR_ORDER_INCREMENT_ID;
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
/**
* change order status to 'Completed'
*/
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();
/**
* change order status to 'Pending'
*/
$order->setState(Mage_Sales_Model_Order::STATE_NEW, true)->save();
/**
* change order status to 'Pending Paypal'
*/
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
/**
* change order status to 'Processing'
*/
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
/**
* change order status to 'Completed'
*/
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();
/**
* change order status to 'Closed'
*/
$order->setState(Mage_Sales_Model_Order::STATE_CLOSED, true)->save();
/**
* change order status to 'Canceled'
*/
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
/**
* change order status to 'Holded'
*/
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true)->save();
Otherwise, you can do it from admin panel as well.