2

I created an Observer that makes some execution based on the company needs using event sales_order_shipment_save_after. It does everything I need except changing the order status to a specific.

I both using Magento setState/setStatus and running an SQL update script directly, but none won´t make the change.

I looked for running a plugin instead of the observer but I could not find where should the plugin fit.

It´s important to let you know that the state is the same as the one set by shipment - complete. Only the status needs to be updated.

$orderState = Order::STATE_COMPLETE;
    $order2 = $objectManager->create('\Magento\Sales\Model\Order')->load($order_id);
    $order2->setState($orderState)->setStatus("entregue_transportadora");

    $order2->save();

Anyone can help me ?

Thanks !!

4
  • Share your code that you have used to update satatus Nov 3, 2019 at 4:17
  • @ShoaibMunir I added the part of the code by the end of the observer that should make the status update but did not work. Thanks ! Nov 3, 2019 at 16:11
  • Make sure entregue_transportadora status is set to complete state. Verify from Stores -> Settings -> Order Status Nov 3, 2019 at 19:06
  • @ShoaibMunir yep it is set to complete state, but it is not default status. The default status for complete is another. When I add the shipment the status is set to the default complete status and won´t change to this one. Nov 4, 2019 at 14:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.