I have an observer in my module the fires when the order is placed, depending on a condition I use

$order->setState(\Magento\Sales\Model\Order::STATE_HOLDED, true)->save();
$order->setStatus(\Magento\Sales\Model\Order::STATE_HOLDED, true)->save();

To set the order status to "on hold", this works but when I try to take the order off hold from the admin it says "the order was not on hold" even though the status is on hold in both sales_order and sales_order_grid

enter image description here

I have also tried with object manager which does the exact same thing (also, the comment is added so it seems like its right):

$orderId = $orderIncrementId;
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $order = $objectManager->create('\Magento\Sales\Model\Order')->load($order_id);
        $currentStatus = $order->getState();
        $status = 'holded';
        $comment = 'Age verification failed';
        $isNotified = false;
        $order->addStatusToHistory($order->getStatus(), $comment);

And I have tried through the order repository (but this didn't work as it's in the observer sales_order_save_after but still says "order id does not exist)

$holdStatus= \Magento\Sales\Model\Order::STATE_HOLDED;

$id = $orderIncrementId;
            $order = $this->orderRepository->get($id);
        } catch (NoSuchEntityException $ex) {
            alert("not worked");

Currently, I'm manually changing the order status to processing in the database to get the orders off hold but as we up-scale the module this won't be practical - does anyone have any idea about this before I create a button that manually changes the status in sales_order and sales_order_grid with direct SQL?

1 Answer 1


You don't want to change the state, and can just do $order->hold()->save();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.