flexponsive
flexponsive

Reputation: 6168

How to update Magento order status without triggering notification email?

After some integration issues with Magento, I need to update the status and state of a few orders. However, since these updates are not really relevant for the customer, I do not want the system to send order notification e-mails for each order update in this case.

What does not work:

$historyItem = $order->addStatusHistoryComment('some comment', 'complete');
$historyItem->setIsVisibleOnFront(false);
$historyItem->setIsCustomerNotified(false);
$historyItem->save();
$order->save();

Upvotes: 2

Views: 2523

Answers (1)

flexponsive
flexponsive

Reputation: 6168

In Mage_Sales_Model_Order_Status_History, you can see that the setIsCustomerNotified method suppresses notification if you provide either parameter null or the value of the constant Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE. Confusingly, using false will lead to the notification being sent.

Updating Magento Order Status without Sending Notification E-Mail to Customer

This code block works - revise order status, adding a comment that is visible only on the backend and will not trigger a notification e-mail 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();

Upvotes: 3

Related Questions