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.

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

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? – vibhu Jun 27 '14 at 8:37
  • @SANKU. Hi how to send sms automatically after place an order in magento-1.9.1.1 like mail. – Teja Bhagavan Kollepara Dec 25 '15 at 5:29
  • @TejabhagavanKollepara magento.stackexchange.com/questions/58453/… – Pradeep Sanku Dec 25 '15 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.