skip to Main Content

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.

2

Answers


  1. In "MagentoSalesModelResourceModelOrder" 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="MagentoSalesModelResourceModelOrder">
        <plugin name="after_plugin_order_state" type="VendorModulePluginPluginName"/>
    </type>
    

    PluginName.php

    public function afterSave(
        MagentoSalesModelResourceModelOrder $subject,
         $result,$object
    ){
        $setCustomStatus = $object->setData('status','Complete');
        return $result
     }
    
    Login or Signup to reply.
  2. It’s in MagentoSalesModelResourceModelOrderHandlerState which is called whenever the Order is saved.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search