I'm want to change the order state processing to newly creates order state, when invoice is created for a order. I want to do this programatically. Anyone help me with this.

1 Answer 1


Try to using sales_order_invoice_pay event, which is fired in adminhtml & frontend scopes.

Update the order state and and status programmatically in order define the status and state. Initiate order object in the construct function and use that order object in the custom function to update it. For Update order state programmatically in model, get order object from the construct function.

public function __construct(
    \Magento\Sales\Model\Order $order
    $this->order = $order;
public function updateorder(){
    $order = $this->order;
    $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true);
    $order->addStatusToHistory($order->getStatus(), 'Order processed successfully with reference');

Hope it helps!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.