Customer not marked as notified programatically Magento

2.6k views Asked by At

add a one new batch action in magento , in this i am changing the status of the order pragmatically

.Its all working fine

but the problem is after changing the status and send email to customer also it is not showing customer notified in comment history

. Below is the code

$order->setIsCustomerNotified(false);
$order->setStatus("ready_for_pickup");
$order->addStatusHistoryComment($comment, false);
$order->save();
$order->sendOrderUpdateEmail($notify = true, $comment);

Can you please suggest me how can i fix this.

thanks

2

There are 2 answers

0
Rohit Goel On

OK i have got the solution and by below piece of code it is working fine now.

$order->setIsCustomerNotified(false);
$order->setStatus("your_order_status");
$historyItem = $order->addStatusHistoryComment($comment, "your_order_status");
$historyItem->setIsCustomerNotified(1)->save();
$order->save();
$order->sendOrderUpdateEmail($notify = true, $comment); 
0
Arslan Tabassum On

We can also send order update email just using sendOrderUpdateEmail. After order save.

$order->save();
$order->sendOrderUpdateEmail($notify = true, 'Replace your comment');