0

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 2

5

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.

  1. sales_order_status_history_save_before,
  2. 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.

0
0

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();
}
3
  • 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?
    – vibhu
    Commented 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

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.