00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Rating_Block_Entity_Detailed extends Mage_Core_Block_Template
00035 {
00036 public function __construct()
00037 {
00038 parent::__construct();
00039 $this->setTemplate('rating/detailed.phtml');
00040 }
00041
00042 protected function _toHtml()
00043 {
00044 $entityId = Mage::app()->getRequest()->getParam('id');
00045 if( intval($entityId) <= 0 ) {
00046 return '';
00047 }
00048
00049 $reviewsCount = Mage::getModel('review/review')
00050 ->getTotalReviews($entityId, true);
00051 if( $reviewsCount == 0 ) {
00052 #return Mage::helper('rating')->__('Be the first to review this product');
00053 $this->setTemplate('rating/empty.phtml');
00054 return parent::_toHtml();
00055 }
00056
00057 $ratingCollection = Mage::getModel('rating/rating')
00058 ->getResourceCollection()
00059 ->addEntityFilter('product') # TOFIX
00060 ->setPositionOrder()
00061 ->setStoreFilter(Mage::app()->getStore()->getId())
00062 ->addRatingPerStoreName(Mage::app()->getStore()->getId())
00063 ->load();
00064
00065 if ($entityId) {
00066 $ratingCollection->addEntitySummaryToItem($entityId, Mage::app()->getStore()->getId());
00067 }
00068
00069 $this->assign('collection', $ratingCollection);
00070 return parent::_toHtml();
00071 }
00072 }