What is the correct way to change order status in Magento 2
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\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.