Skip to main content

It is good and you followed good approach as per M2 standards. It needs some improvement to make it compatible and error-free in a maximum of cases

  1. Exception Handling.

    $order = $observer->getEvent()->getOrder(); if( !empty($order) ){ // do code here }$order = $observer->getEvent()->getOrder(); if( !empty($order) ){ // do code here }

  2. Naming convention. Do use camel-case for variables. $order_status should be $orderStatus.

  3. It is observer so you wontwon't be able to track if that happened or not so do wrap it in try-catch and log accordingly ( do add a check if logs are enabled or not ).

It is good and you followed good approach as per M2 standards. It needs some improvement to make it compatible and error-free in maximum of cases

  1. Exception Handling.

    $order = $observer->getEvent()->getOrder(); if( !empty($order) ){ // do code here }

  2. Naming convention. Do use camel-case for variables. $order_status should be $orderStatus.

  3. It is observer so you wont be able to track if that happened or not so do wrap it in try-catch and log accordingly ( do add check if logs are enabled or not ).

It is good and you followed good approach as per M2 standards. It needs some improvement to make it compatible and error-free in a maximum of cases

  1. Exception Handling. $order = $observer->getEvent()->getOrder(); if( !empty($order) ){ // do code here }

  2. Naming convention. Do use camel-case for variables. $order_status should be $orderStatus.

  3. It is observer so you won't be able to track if that happened or not so do wrap it in try-catch and log accordingly ( do add a check if logs are enabled or not ).

Source Link

It is good and you followed good approach as per M2 standards. It needs some improvement to make it compatible and error-free in maximum of cases

  1. Exception Handling.

    $order = $observer->getEvent()->getOrder(); if( !empty($order) ){ // do code here }

  2. Naming convention. Do use camel-case for variables. $order_status should be $orderStatus.

  3. It is observer so you wont be able to track if that happened or not so do wrap it in try-catch and log accordingly ( do add check if logs are enabled or not ).