Using Magento ver. 2.0.7 I am trying to use this code to change order to the status of "Processing", but i get an error, i think i am missing some prerequisite to call, but i can't figure it out.

[25-Oct-2016 13:11:30 America/Detroit] PHP Fatal error: Class 'Magento\Framework\App\ObjectManager' not found in /chroot/home/testplat/test.platinait.ca/html/pub/orderstatus.php on line 4


$orderId = 000000193;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('\Magento\Sales\Model\Order')



2 Answers 2


We can set order status like.

$orderId = 000000193;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order_status = $objectManager->get('Magento\Sales\Mode\Order')->load($orderId);

Recommended to do this by creating custom module as well as passing the class in to constructor as a dependency.

  • i think i am missing a dependancy call because i get the same class missing message here too. Oct 25, 2016 at 21:04
  • Yes, create a custom module and use this code there as a Yes, create a custom module and use this code there as a dependency.. Oct 26, 2016 at 4:13

You should use 'getResource' method. Direct load, save and delete are deprecated in Mangeto >= 2.1.0.

Example :

  • how does order_status know which order it is working on if your not pulling load($orderId) anymore? (or have i misinterpreted something here) Oct 25, 2016 at 21:03
  • always use getResource for those methods. Or you can just inject OrderRepository and use get($id) and save($order) method
    – 95623
    Oct 26, 2016 at 16:24
  • btw: aboute objectManager read this answere : magento.stackexchange.com/questions/117098/…
    – 95623
    Oct 26, 2016 at 16:42

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.