Tutorialsplane

Magento 2 change order status programmatically


Magento 2 change order status programmatically- We sometimes need to update order status programmatically in Magento 2, we can use object manager to update the order status. Here in this tutorial, we are going to explain how you can change order status programmatically in magento 2.


Magento 2 change order status programmatically Example

You can change order status in Magento 2 simply as below-

Example:

$orderId = 100;
$objManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objManager->create('\Magento\Sales\Model\Order') ->load($orderId);
$newState = Order::STATE_PROCESSING;
$order->setState($newState)->setStatus(Order::STATE_PROCESSING);
$order->save();

On the same way you can update order status for particular order.