2

I am generating XML which is sent to an external system whenever a Credit Memo is generated. I am using the event sales_order_creditmemo_refund which gives me the credit memo and order models (which I am using to generate the appropriate XML)

$creditMemo = $observer->getEvent()->getCreditmemo();
$order      = $creditMemo->getOrder();

However I am having trouble accessing comments. I can see in Mage_Sales_Model_Order_Creditmemo there is getCommentsCollection() but this is not returning anything.

I am guessing the comments are added to the model at a later stage, should I be using a different event for my observer?

I can see that Mage::dispatchEvent('sales_order_creditmemo_refund', array($this->_eventObject=>$this)); is located inside the refund() method of the same model, but the only other event I can see in the model is sales_order_creditmemo_cancel

1
  • have you try: sales_order_creditmemo_save_after
    – lloiacono
    Commented Jul 27, 2015 at 15:02

1 Answer 1

0

Ok so after posting the question I immediately find the answer!

For anyone else with this issue:

Checking the saveAction() within Mage_Adminhtml_Sales_Order_CreditmemoController reveals that the comments are initially only added to the session:

$data = $this->getRequest()->getPost('creditmemo');
if (!empty($data['comment_text'])) {
   Mage::getSingleton('adminhtml/session')->setCommentText($data['comment_text']);
}

So from within the observer I can simply call Mage::getSingleton('adminhtml/session')->getCommentText() to return the comment.

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.