5

I need to send an offer email to customers, if their review is approved.

I can't find one. How can I list all the events available in Magento?

What hook/event can I use?

In Magento 1.9 version:

<?>
    <observers>
        <your_module>
            <type>singleton</type>
            <class>your_module/observer</class>
            <method>yourMethod</method>
        </your_module>
    </observers>
</?>

2 Answers 2

7

As stated by Rakesh, the review_save_after is the event you need.

However, this will be triggered whenever you save a review even if you don't approve it.

Thus in your observer you need to check if the review is being approved:

$review = $observer->getDataObject();

// Check if there are changes
if ($review->hasDataChanges()) {
    // Get the old status
    $oldStatus = $review->getOrigData('status_id');
    // Get the new status
    $newStatus = $review->getData('status_id');
    // Check if they are different and if the new one is approved
    if ($newStatus != $oldStatus && $newStatus == Mage_Review_Model_Review::STATUS_APPROVED) {
        // Send email to customer
    }
}
7
  • i added the event in admin <review_save_after> <observers> ... it don't trigger Jun 24, 2016 at 12:49
  • 1
    @manokarthickkarthick how do you know it's not triggered ? Jun 24, 2016 at 12:51
  • by var_dump($review);exit; in my observer function. it doesn't exited, just runs as usual Jun 24, 2016 at 12:53
  • @manokarthickkarthick what if you call Mage::log("test"); instead of var_dump($review);exit; and check your var/log/system.log file ? Jun 24, 2016 at 12:55
  • it don't create any log Jun 24, 2016 at 13:26
2

you can try with <review_save_after>

<review_save_after>
 <observers>
      <your_module>
        <type>singleton</type>
        <class>your_module/observer</class>
        <method>yourMethod</method>
      </your_module>
    </observers>
</review_save_after>
3
  • will it work from admin also? Jun 24, 2016 at 12:41
  • 1
    Type is singleton by default, doesn't need to be specified
    – scrowler
    Jun 24, 2016 at 12:42
  • i havent try with may be its working after save using admin, This is the main event of review so its working Jun 24, 2016 at 12:42

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.