0

I have the following script in custom module to change an order from processing to a custom order's status

$order->setStatus(\MyNamespace\Mymodule\Model\Order::STATUS_PRINTED);
$this->orderRepository->save($order);

i found that the status field in sales_order is updated, but the status field in sales_order_grid is not updated (occur in magento 2.2.6 commerce edition, but ok in 2.3 ce edition).

Anyone has idea what is the possible problem.

1 Answer 1

0

I am currently using magento226. I tested it for the situation you said, and there is no such situation. can you try this code and let me see what happens.

            // test code
            $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
            $orderRepository = $objectManager->create(\Magento\Sales\Api\OrderRepositoryInterface::class);
            $orderId = "xxxxx";
            $order = $orderRepository->get($orderId);
            $order->setStatus('test');
            $order->save();
            //$orderRepository->save($order);
1
  • i don't know why 2.2.6 need me run a command to update the column at sales_order table bin/magento cron:run
    – hkguile
    Sep 5, 2019 at 9:38

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.