After placing an order, my module calls an external API.
If success from external API, I need to update the order status.
I know how to update status in Magento 1 but how do you do this in Magento 2?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
\Magento\Sales\Api\OrderRepositoryInterface::save. This is public API of sales module and after future Magento releases will not change, so your custom module will not be broken.
Magento 1 style (manipulations with models an resource models directly from third party modules) should not be used in case when suitable public API is available (such classes/methods are marked with
@api tag). Such approach will lead to custom module being broken after the next Magento 2 releases.