Update order status programmatically in magento

We can update order status of product in magento by using this below code. setState() function will do this for us, all we need is just pass the required arguments like state to be updated, status of the state, comment for the status change.


$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$state = 'new';
$status = 'label_generated_by_user';
$comment = 'You have generated you shipping label';
$isCustomerNotified = true;
$order->setState($state, $status, $comment, $isCustomerNotified);
$order->save();
$order->sendOrderUpdateEmail(true, $comment);//Sending email notification to customer.

After updating order we can send notification to customer by using sendOrderUpdateEmail().

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: