In magento2 back end when I submit shipment the order status will changes from processing to complete but I can't find where the code execute this
can any one tell me where I can find the code?
I use magento2.4.3-p1
I found the code in "vendor/magento/module-sales/Model/Order/Shipment.php" when execute this method “_saveShipment” the status will changel,but I don't know why.
CodePudding user response:
In "Magento\Sales\Model\ResourceModel\Order" there is a function Save(). Within the function you can retrieve and modify value of 'status' of Order. Writing a plugin is preferable.
di.xml
<type name="Magento\Sales\Model\ResourceModel\Order">
<plugin name="after_plugin_order_state" type="Vendor\Module\Plugin\PluginName"/>
</type>
PluginName.php
public function afterSave(
\Magento\Sales\Model\ResourceModel\Order $subject,
$result,$object
){
$setCustomStatus = $object->setData('status','Complete');
return $result
}
CodePudding user response:
It's in \Magento\Sales\Model\ResourceModel\Order\Handler\State which is called whenever the Order is saved.