I have a use case where I need to update the order status (e.g. set to 'completed). In magento 1 I just called setStatus and then save


But for magento 2 I get "function setStatus not found"

How do I update order fields such as status and other fields in Magento 2?

  • my bad...not calling setState correctly (forgot hyphen "-") using $order>setState(), should be $order->setState()
    – user20719
    Commented Dec 14, 2015 at 23:09
  • $saveItem = $item->load($item['item_id'],'item_id'); $saveItem->setPrice(1); $saveItem->setBasePrice(1); $saveItem->save(); I am facing this problem with items Commented Dec 19, 2015 at 20:18

1 Answer 1


Use \Magento\Sales\Model\Order class for the same. (But you should always use repository interface as Magento wont change those frequently.)

protected $order;
    public function __construct(
            \Magento\Sales\Model\Order $order
        ) {
            $this->_order = $order;

Now in your function do something like this.

public function yourFunction(){
   $ordData = $this->_order->load($id=your order id here);
   $ordData->setCustomerFirstname('name goes here');
   $ordData->setCustomOrderAttribute('custom order data goes here'); 
   # set your field name instead of `setCustomOrderAttribute`

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.