My requirement is programatically change the order status to Canceled by using order id.
How to achieve this?
magento-2.0magento2order-statusorders
My requirement is programatically change the order status to Canceled by using order id.
How to achieve this?
Best Answer
Even though using the
OrderFactory
would work,save
andload
methods are deprecated soon, you should use service contracts instead.So you can use
Magento/Sales/Api/OrderManagementInterface
:First inject an instance in your class constructor:
Then use the following: