I have created my own function which is trigged for the event sales_order_status_history_save_after. What I wanted to do is, when a new comment is added, the system will get the latest order comment, and send it to customer.

I have tried using the following code,

    public function CommentSaveAfter()
            $history = $order->getStatusHistoryCollection()->getFirstItem();
            return $history->getComment();


However, this code only get me the last comment before the new one is added.

See screenshot, the code only get the last comment 4444, not 5555 when I click on "Submit Comment" enter image description here

How can I get the latest comment when click on Submit Comment with event sales_order_status_history_save_after ?

This question is not duplicated with Magento event for adding order comment

My problem is I can not get the comment I just added to the order comment, but only the latest comment from status_history. I have already managed to add my own function to the event sales_order_status_history_save_after. So it's different from the other question.


2 Answers 2


Event to use when order comment is post

You can use sales_order_status_history_save_before or sales_order_status_history_save_afterand you will get the comment you are saving as an object using


Chances are that your collection is already loaded. I don't know if $order->getStatusHistoryCollection() returns a cached collection or not. Otherwise you could try resetting/reloading the collection:

$collection = $order->getStatusHistoryCollection();

Haven't tested it since I haven't touched Magento 1 in almost 2 year now.

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.