In this article I'm describing how you send an email notification to admin email address every time a new review has been posted. I am planning to do this by making a custom module which on its own as soon as the new review is posted should notify the store owner (on its contact email address).
This module allows you to send product review email directly to administrator when customer submits product review on your website. For this I'm going to make it by "review_save_after" event.
First of all, Crate a skeleton module(for example: Prashant_Reviewnotify) and register the event: review_save_after
File: app/code/local/Prashant/Reviewnotify/etc/config.xml
<frontend> ... <events> <review_save_after> <observers> <prashant_reviewnotify_review_save_after> <type>singleton</type> <class>prashant_reviewnotify/observer</class> <method>reviewSaveAfter</method> </prashant_reviewnotify_review_save_after> </observers> </review_save_after> </events> ... </frontend>
After that, Implement the observer model
File: app/code/local/Prashant/Reviewnotify/Model/Observer.php
<?php class Prashant_Reviewnotify_Model_Observer { /** * Send notification email when product review is posted * * @param Varien_Event_Observer $observer */ public function reviewSaveAfter(Varien_Event_Observer $observer) { $review = $observer->object; if ($review) { $emails = array('info@prashantblog.com'); #Edit admin emails try { //@todo - use configurable email templates $this->_sendNotificationEmail($emails, $review); } catch (Exception $e) { Mage::logException($e); } } else { Mage::log('ERROR::UNABLE TO LOAD REVIEW'); } } protected function _sendNotificationEmail($emails, $review) { if (count($emails)) { $product = Mage::getModel('catalog/product')->load($review->getEntityPkValue()); $starRatings = array_values($review->getRatings()); $body = 'New product review has been posted!<br /><br />'; $body .= 'Customer Name: ' . $review->getNickname() . '<br />'; $body .= 'Product: ' . sprintf('<a href="%s" target="_blank">%s</a>', $product->getProductUrl(), $product->getName()) . '<br />'; $body .= 'Star Rating: ' . (isset($starRatings[0]) ? $starRatings[0] : 'N/A') . '<br />'; $body .= 'Review Title: ' . $review->getTitle() . '<br />'; $body .= 'Review Description: ' . $review->getDetail() . '<br />'; foreach ($emails as $toEmail) { $mail = Mage::getModel('core/email'); $mail->setToName('YourStore Name'); $mail->setToEmail($toEmail); $mail->setBody($body); $mail->setSubject('YourStore: New Product Review'); $mail->setFromEmail('donotreply@prashantblog.com'); $mail->setFromName("YourStore"); $mail->setType('html'); try { $mail->send(); } catch (Exception $e) { Mage::logException($e); } } } } } ?>
Can possible add product review and rating on email after customer purchased new product .then after review and rating data store in magento pending review table.