*/ class Mage_Rss_Block_Catalog_Review extends Mage_Rss_Block_Abstract { /** * Cache tag constant for feed reviews * * @var string */ const CACHE_TAG = 'block_html_rss_catalog_review'; /** * Initialize cache * * @return null */ protected function _construct() { $this->setCacheTags(array(self::CACHE_TAG)); /* * setting cache to save the rss for 10 minutes */ $this->setCacheKey('rss_catalog_review'); $this->setCacheLifetime(600); } /** * Render XML response * * @return string */ protected function _toHtml() { $newUrl = Mage::getUrl('rss/catalog/review'); $title = Mage::helper('rss')->__('Pending product review(s)'); Mage::helper('rss')->disableFlat(); $rssObj = Mage::getModel('rss/rss'); $data = array( 'title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8', ); $rssObj->_addHeader($data); $reviewModel = Mage::getModel('review/review'); $collection = $reviewModel->getProductCollection() ->addStatusFilter($reviewModel->getPendingStatus()) ->addAttributeToSelect('name', 'inner') ->setDateOrder(); Mage::dispatchEvent('rss_catalog_review_collection_select', array('collection' => $collection)); Mage::getSingleton('core/resource_iterator')->walk( $collection->getSelect(), array(array($this, 'addReviewItemXmlCallback')), array('rssObj'=> $rssObj, 'reviewModel'=> $reviewModel)); return $rssObj->createRssXml(); } /** * Format single RSS element * * @param array $args * @return null */ public function addReviewItemXmlCallback($args) { $rssObj = $args['rssObj']; $row = $args['row']; $store = Mage::app()->getStore($row['store_id']); $urlModel = Mage::getModel('core/url')->setStore($store); $productUrl = $urlModel->getUrl('catalog/product/view', array('id' => $row['entity_id'])); $reviewUrl = Mage::helper('adminhtml')->getUrl( 'adminhtml/catalog_product_review/edit/', array('id' => $row['review_id'], '_secure' => true, '_nosecret' => true)); $storeName = $store->getName(); $description = '
'
. $this->__('Product: %s
', $productUrl, $row['name'])
. $this->__('Summary of review: %s
', $row['title'])
. $this->__('Review: %s
', $row['detail'])
. $this->__('Store: %s
', $storeName )
. $this->__('click here to view the review', $reviewUrl)
. '