Before solution I would like to show first attempt that I tried but failed to get desired result.
<block type="review/product_view" name="product.review" as="reviews" template="review/helper/summary.phtml"> <block type="core/template" name="product_review_list.count" template="review/product/view/count.phtml"/> <action method="addToParentGroup"><group>detailed_info</group></action> <action method="setTitle" translate="value"><value>Review</value></action> <action method="getReviewsSummaryHtml" translate="title" module="review"> <product helper="tcatalog/currentProduct"/> <templateType>false</templateType> <displayIfNoReviews>true</displayIfNoReviews> </action> </block>
Now the solution that worked for me:
app\code\community\Technooze\Treview\Block\Reviews.php
<?php class Technooze_Treview_Block_Reviews extends Mage_Core_Block_Template { public function _prepareLayout() { return parent::_prepareLayout(); } public function getRatingSummary() { $storeId = Mage::app()->getStore()->getStoreId(); $summaryData = Mage::getModel('review/review_summary') ->setStoreId($storeId) ->load(Mage::registry('product')->getId()); return $summaryData->getData('rating_summary'); } public function getReviewsCount() { $storeId = Mage::app()->getStore()->getStoreId(); $summaryData = Mage::getModel('review/review_summary') ->setStoreId($storeId) ->load(Mage::registry('product')->getId()); return $summaryData->getData('reviews_count'); } public function getReviewsUrl() { return Mage::getUrl('review/product/list', array( 'id' => Mage::registry('product')->getId(), 'category' => Mage::registry('product')->getCategoryId() )); } public function getFirstReview() { $data = array(); $sum = Mage::getModel('review/review')->getCollection() ->addStoreFilter(Mage::app()->getStore()->getId()) ->addStatusFilter('approved') ->addEntityFilter('product', Mage::registry('product')->getId()) ->getFirstItem() ->setDateOrder(); if($reviewer = $sum->getNickname()) { $data['review'] = $sum->getDetail();
$data['reviewer'] = $reviewer; } else { $data = false; } return $data; } }
On layout add this:
<block type="treview/reviews" name="treview_short_review" template="review/helper/summary_view.phtml"> <action method="addToParentGroup"><group>detailed_info</group></action> <action method="setTitle" translate="value"><value>Reviews</value></action> </block>
Now we need summary view template file:
app\design\frontend\enterprise\responsive\template\review\helper\summary_view.phtml
<div class="view-stars"> <h4>Customer Reviews and Ratings</h4> <div class="ratings"> <div class="rating-box" title="<?php echo $this->getRatingSummary() ?>%"> <div class="rating" style="width:<?php echo $this->getRatingSummary() ?>%"></div> </div> <br /> <p class="rating-links"> <a href="<?php echo $this->getReviewsUrl() ?>"><?php echo $this->__('%d review(s)', $this->getReviewsCount()) ?></a> | <a href="<?php echo $this->getReviewsUrl() ?>#review-form"><?php echo $this->__('Write a Review') ?></a> </p> </div> </div>
Find full code on github at: https://github.com/dbashyal/Magento-Product-Review