Can anyone please let me know if there is any magento event available for adding comment to a particular order? Let me know if question is not clear.
2 Answers
So firstly you have to think about what a comment is. In the case of the order a comment is simply a field on the table sales_flat_order_status_history
. So a comment itself cannot be track so easily. What I would suggest is that you look into the before and after save events for this model.
sales_order_status_history_save_before
,sales_order_status_history_save_after
What you can do with these events, as you will have the history object is then check to see if the comment attribute is null or not and then do what you wanted.
If the comment is not null then this can be treated as the saving of a comment on an order.
you can use following event in config.xml
<events>
<sales_order_place_after>
<observers>
<someeventname>
<type>singleton</type>
<class>modulename/observer</class>
<method>ordercomment</method>
</someeventname>
</observers>
</sales_order_place_after>
</events>
public function ordercomment($observer)
{
$_order = $observer->getEvent()->getOrder();
$_order->addStatusToHistory($_order->getStatus(),'some messagge',false);
$_order->save();
}
-
Thanks for your quick reply but i need an event which is solely run for adding comment to order. will it (sales_order_place_after) work even we add comment to an order which is already placed?– vibhuCommented Jun 27, 2014 at 8:37
-
@SANKU. Hi how to send sms automatically after place an order in magento-1.9.1.1 like mail. Commented Dec 25, 2015 at 5:29
-
@TejabhagavanKollepara magento.stackexchange.com/questions/58453/… Commented Dec 25, 2015 at 14:22