Try to change the order state from a file within the Magento root directory.
What I did:
- 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');
I already get the order ID from database.
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!