0

Try to change the order state from a file within the Magento root directory.

What I did:

  1. Connected to Magento engine and included the object manager:
 // Start Magento engine use Magento\Framework\App\Bootstrap; require __DIR__ . '/app/bootstrap.php'; $params = $_SERVER; $bootstrap = Bootstrap::create(BP, $params); $obj = $bootstrap->getObjectManager(); $state = $obj->get('Magento\Framework\App\State'); $state->setAreaCode('frontend'); 
  1. I already get the order ID from database.

  2. Now I try to change order state:

 $order = $obj->get('Magento\Sales\Model\Order') ->load($orderId); $orderState = Order::STATE_PROCESSING; $order->setState($orderState)->setStatus(Order::STATE_COMPLETE); $order->save(); 

But this throws error:

 Fatal error: Uncaught Error: Class 'Order' not found in [FILE]:633 Stack trace: #0 {main} thrown in [FILE] on line 633

I tried and searched, but had no luck. Thanks for any help!

2
  • which error ????? Commented Aug 25, 2021 at 6:16
  • Fatal error: Uncaught Error: Class 'Order' not found in [FILE]:633 Stack trace: #0 {main} thrown in [FILE] on line 633 Commented Aug 25, 2021 at 9:10

1 Answer 1

0

Try this :-

$order = $obj->get('Magento\Sales\Model\Order')->load($orderId); $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING) ->setStatus(\Magento\Sales\Model\Order::STATE_COMPLETE); $order->save(); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.