Saving custom attribute in observer for checkout success


Since the $order->save() method is deprecated, would it be enough just to do this in my observer:

<?php namespace MyVendorMyModuleObserver; class SetOrderAttribute implements MagentoFrameworkEventObserverInterface { /** * @param MagentoFrameworkEventObserver $observer * @return $this */ public function execute(MagentoFrameworkEventObserver $observer) { /** @var MagentoSalesModelOrder $order */ $order = $observer->getEvent()->getOrder(); if($order->getMustValidate() == 1) { $order->setStatus('validate')->setState('processing'); //$order-save() - removed since it's deprecated. } return $this; } } 


 <event name="checkout_onepage_controller_success_action"> <observer name="set_order_attribute" instance="MyVendorMyModuleObserverSetOrderAttribute" /> </event> 

Will Magento take care of persisting my status change to the order ?

submitted by /u/Screemoh
[link] [comments]