Bhaveshpp

Professional Magento Developr - Healp eachother to grow

Magento2: How to update order stae and status

27 May 2021 » magento2, magento2-order

Update order state and status programetically


use Magento\Sales\Model\Order;

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