How to update Magento order status without triggering email notification?

After some integration issues with Magento, I need to update the status and status of several orders. However, since these updates are not very relevant for the client, I do not want the system to send emails with a notification in order for each update of the order in this case.

What does not work:

$historyItem = $order->addStatusHistoryComment('some comment', 'complete'); $historyItem->setIsVisibleOnFront(false); $historyItem->setIsCustomerNotified(false); $historyItem->save(); $order->save(); 
+2
source share
1 answer

In Mage_Sales_Model_Order_Status_History you can see that the setIsCustomerNotified method suppresses the notification if you specify the null parameter or the value of the constant Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE . Confusingly, using false will send a notification.

Magento order status update without sending e-mail notifications to the client

This code block works - revises the status of the order, adding a comment that is visible only on the backend and will not cause a notification to the client:

 $historyItem = $order->addStatusHistoryComment('some comment', 'complete'); $historyItem->setIsVisibleOnFront(false); $historyItem->setIsCustomerNotified(Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE); $historyItem->save(); $order->save(); 
+3
source

Source: https://habr.com/ru/post/1501410/


All Articles