I'm using the code below for change order status to holded


But after run this code, the status of order is blank, what am i wrong ? enter image description here


You code seems well. But ensure that holded is the default status of order state holded.

Using $order->setState("holded")->setStatus("holded"); means automatically not changes the order status to hold.

before changes an order status to hold, you have to check the order is available for the hold by canHold().

if ($order->canHold()) {

If you want do this at a class then use below

 protected $orderManagement;
public  function __construct(
    \Magento\Sales\Api\OrderManagementInterface $orderManagement
    $this->orderManagement = $orderManagement;
public function canChangetoHold()

    try {
        $this->orderManagement->hold(10); //10 is order id

    } catch (\Magento\Framework\Exception\LocalizedException $e) {
        // some error
    } catch (\Exception $e) {
        //You have not put the order on hold
| improve this answer | |
  • I also found code on the file : vendor/magento/module-sales/Controller/Adminhtml/Order/Hold.php – Magetop E-commerce Aug 21 '18 at 6:43
  • YEs, you will get code at there. – Amit Bera Aug 21 '18 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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