*/ class Mage_Review_Block_Customer_View extends Mage_Catalog_Block_Product_Abstract { public function __construct() { parent::__construct(); $this->setTemplate('review/customer/view.phtml'); $this->setReviewId($this->getRequest()->getParam('id', false)); } public function getProductData() { if( $this->getReviewId() && !$this->getProductCacheData() ) { $product = Mage::getModel('catalog/product') ->setStoreId(Mage::app()->getStore()->getId()) ->load($this->getReviewData()->getEntityPkValue()); $this->setProductCacheData($product); } return $this->getProductCacheData(); } public function getReviewData() { if( $this->getReviewId() && !$this->getReviewCachedData() ) { $this->setReviewCachedData(Mage::getModel('review/review')->load($this->getReviewId())); } return $this->getReviewCachedData(); } public function getBackUrl() { return Mage::getUrl('review/customer'); } public function getRating() { if( !$this->getRatingCollection() ) { $ratingCollection = Mage::getModel('rating/rating_option_vote') ->getResourceCollection() ->setReviewFilter($this->getReviewId()) ->addRatingInfo(Mage::app()->getStore()->getId()) ->setStoreFilter(Mage::app()->getStore()->getId()) ->load(); $this->setRatingCollection( ( $ratingCollection->getSize() ) ? $ratingCollection : false ); } return $this->getRatingCollection(); } public function getRatingSummary() { if( !$this->getRatingSummaryCache() ) { $this->setRatingSummaryCache(Mage::getModel('rating/rating')->getEntitySummary($this->getProductData()->getId())); } return $this->getRatingSummaryCache(); } public function getTotalReviews() { if( !$this->getTotalReviewsCache() ) { $this->setTotalReviewsCache(Mage::getModel('review/review')->getTotalReviews($this->getProductData()->getId()), false, Mage::app()->getStore()->getId()); } return $this->getTotalReviewsCache(); } public function dateFormat($date) { return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_LONG); } /** * Check whether current customer is review owner * * @return boolean */ public function isReviewOwner() { return ($this->getReviewData()->getCustomerId() == Mage::getSingleton('customer/session')->getCustomerId()); } }