Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Making customer reviews appear on the product info page
 
Sintax
Member
 
Total Posts:  58
Joined:  2008-02-18
Hungary
 

Hi,

I want to get the customer reviews to appear on the product info page rather than having to click the link for the reviews. I want to create a tabbed layout for the page.

Here is what I did:

I modified catalog/product/view.phtml and removed this:

<?=$this->helper('review/product')->getSummaryHtml($_productnull1)?>

Then I tracked down how to get the review count and the rating average:

if( !$_product->getRatingSummary() ) {
        Mage
::getModel('review/review')->getEntitySummary($_productMage::app()->getStore()->getId());
    
}
    $numReviews 
$_product->getRatingSummary()->getReviewsCount();
    
$ratingSummary $_product->getRatingSummary()->getRatingSummary();

Then I wanted to list all the reviews in the page:

<?
                $productId 
$_product->getId();
                
$_collectionX Mage::getModel('review/review')->getCollection();
                
$_collectionX->addStoreFilter(Mage::app()->getStore()->getId())->addStatusFilter('approved')->addEntityFilter('product'$productId)->setDateOrder();
                
?>
                
<div class="collateral-box dedicated-review-box" id="customer-reviews">
            <
div class="head">
                <
h4><?=$this->__('Customer Reviews')?></h4>
            </
div>
        
            <
ol style="margin-top:15px;">
        
<?foreach$_collectionX->getItems() as $_reviewX ):?>
                
<li>
                
<? var_dump($_reviewX); ?>
                    
<a href="<?=$this->getReviewUrl($_reviewX->getId())?>"><strong><?=$_reviewX->getTitle()?></strong></a<?=$this->__('Review by %s'$_reviewX->getNickname())?>
                    
<table class="ratings-list" cellspacing="0">
                        <
tbody>
                       
<?foreach$_reviewX->getRatingVotes() as $_voteX ):?>
                        
<tr>
                            <
td class="label"><strong><?=$_voteX->getRatingCode()?></strong></td>
                            <
td>
                                <
div class="rating-box">
                                    <
div class="rating" style="width: <?=$_voteX->getPercent()?>%;"></div>
                                </
div>
                            </
td>
                        </
tr>
                        
<?endforeach;?>
                        
</tbody>
                    </
table>
                    <
p><?=nl2br($_reviewX->getDetail())?> <?=$this->__('(Posted on %s)'$this->formatDate($_reviewX->getCreatedAt()), 'long')?></p></li>
                <
li>
        
<?endforeach;?>
            
</ol>
Which only partially worked. I got the review date, the reviewer and the content, however I couldn’t get the rating, since it kept complaining the the foreach parameter is incorrect ( $_reviewX->getRatingVotes() as $_voteX ).

Does anyone know what could be wrong?

::Sintax

 
Magento Community Magento Community
Magento Community
Magento Community
 
katiek648
Member
 
Total Posts:  33
Joined:  2008-04-10
 

I’m looking to also place the reviews/rating on the product page. However, I tried the code above, but there is obviously additional items to add in that code here:

<div class="review_details">
            
<?php echo $_review->title ?>
            
...
        </
div>
Can someone show me what additional code I need? I would like for everything to show up like it is on the review page with title, reviewed by, rating, description, posted date.

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

It is preferred to use methods to retrieve object data:

$_review->getTitle();

To see all object data use ->debug() method:

<pre><?php echo print_r($_review->debug());?></pre>
 
Magento Community Magento Community
Magento Community
Magento Community
 
lisali
Enthusiast
 
Avatar
Total Posts:  889
Joined:  2008-04-28
London, UK
 

Eh - I am a bit confused now...could someone please, please post a complete guide on how to do this?

Ideally - this should be configurable from the back-end, but for now - how would I go about adding the review to the product info page?

Many thanks!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
lisali
Enthusiast
 
Avatar
Total Posts:  889
Joined:  2008-04-28
London, UK
 

Anyone? Please? Any updates?

smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
benaschkade
Jr. Member
 
Total Posts:  10
Joined:  2008-09-03
 

Updates? Please? I spent the whole day trying to make this work and utterly failed. Doh!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Consofas
Jr. Member
 
Total Posts:  29
Joined:  2008-05-21
 

Full code I have used in catalog/product/view.phtml around line 109

<?php $_reviews Mage::getModel('review/review')->getCollection()
                                    ->
addStoreFilter(Mage::app()->getStore()->getId())
                                   ->
addEntityFilter('product'$_product->getId())
                                   ->
addStatusFilter('approved')
                                   ->
addRateVotes()
                                   ->
setDateOrder(); ?>
        
<div class="collateral-box dedicated-review-box" id="customer-reviews">
            <
div class="head">
                <
h4>Customer Reviews</h4>
            </
div>
            
<?php if($_reviews->count()): ?>
            <?php 
foreach ($_reviews->getItems() as $_review): ?>
                <?php 
foreach( $_review->getRatingVotes() as $_vote ): ?>
                        <?php 
echo $_vote->getRatingCode() ?>
                        
<div class="rating-box">
                            <
div class="rating" style="width: <?php echo $_vote->getPercent() ?>%;"></div>
                        </
div>
                    
<?php endforeach; ?>
                
<div class="review_details">
                    <
h4><a href="<?=$this->getReviewUrl($_review->getId())?>"><?php echo $_review->title ?></a></h4>
                    <
p><?=nl2br($_review->getDetail())?></p>
                    <
p><?=$this->__('(Posted on %s)'$this->formatDate($_review->getCreatedAt()), 'long')?> <?=$this->__('Review by %s'$_review->getNickname())?></p>
                </
div>
            
<?php endforeach; ?> 
                
<p><a href="http://www.powermillblender.com/store/review/product/list/id/7/#review-form">Add your review</a></p>
            
<?php else: ?>
                
<p><a href="http://www.powermillblender.com/store/review/product/list/id/7/#review-form">Be the first to review this product</a></p>
            
<?php endif; ?>
        
</div>
Unfortunately on the actual review page the reviews now show up twice!
Once I figure that one out I will update this post.
 
Magento Community Magento Community
Magento Community
Magento Community
 
Consofas
Jr. Member
 
Total Posts:  29
Joined:  2008-05-21
 

Thanks to sintax and danieln who started this, Not sure I could have figured it out without your code in the posts above.

 
Magento Community Magento Community
Magento Community
Magento Community
 
benaschkade
Jr. Member
 
Total Posts:  10
Joined:  2008-09-03
 

Thanks guys for help! Ya’ll rock!

 
Magento Community Magento Community
Magento Community
Magento Community
 
dosplus
Jr. Member
 
Avatar
Total Posts:  23
Joined:  2008-08-14
 

Unfortunately on the actual review page the reviews now show up twice!
Once I figure that one out I will update this post.

Anybody found the answer to this problem.... i have the same problem.

Thanks, Martin

 
Magento Community Magento Community
Magento Community
Magento Community
 
bloggleme
Sr. Member
 
Avatar
Total Posts:  101
Joined:  2008-05-06
 

I also am experiencing double ratings! This is ridiculous. And it looks retarded to our visitors… Is there a fix yet?

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 

According to my test, actually, it’s not duplicating the ratings. The problem is that labels for ‘quality’, ‘price’ and ‘value’ are not showing up in the frontend but in source code (likely to do with absolute positioning of the stars and z-index).
So, the choice would be whether to show summary of ratings or full description of ratings.

I am trying to test out the full description of ratings. Will post back if I get any further.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 

The code ‘ <?php echo $_vote->getRatingCode() ?>’ generates rating’s labels too, and likely due to the absolute positioning they are overlapped by the rating stars.

So one quick fix for you guys is using table instead of div for rating section.

<?php foreach ($_reviews->getItems() as $_review): ?>
<table class="ratings-list" cellspacing="0">
<?php foreach ($_review->getRatingVotes() as $_vote): ?>
<tr>
<td class="label"><strong><?php echo $_vote->getRatingCode() ?></strong></td>
<td>
<div class="rating-box">
<div class="rating" style="width: <?php echo $_vote->getPercent() ?>%;"></div>
</div>
</td>
</tr>
<?php endforeach; ?>
</table>

Oh my buddha! I can’t believe I suggest using table!

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 

Anybody know how to improve this review section in the review page?

I dug up this very old thread, and think YoavKutner made a very good point. Still, it’s very useful to have review in the product page - ideally, for SEO and UI, it would be perfect to have something like ‘Most Recent Customer Reviews’ in the product view page with a limit, say, up to 5 reviews listed. If more than 5 reviews, a link with ‘read more reviews’ brings user to a full review page.

So the working code posted in this thread can be served as the ‘’Most Recent Customer Reviews’’, and a ‘read more reviews’ links to the magento default review page. I tried to bring the toolbar but it’s not working.

 
Magento Community Magento Community
Magento Community
Magento Community
 
brankonagy
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2008-05-20
Odranci, Slovenia
 
katiek648 - 08 May 2008 02:02 PM

I’m looking to also place the reviews/rating on the product page. However, I tried the code above, but there is obviously additional items to add in that code here:

katiek648 - 08 May 2008 02:02 PM

Can someone show me what additional code I need

Fastest way?
- copy inputs from review form (...template/review/form.phtml, dont forget boxes like ‘validate_rating’, etc...)
- nest them somewhere on custom view.phtml template
- add submit button to post elements to .../review/products/post/’your_product_id’
- and thats it

 
Magento Community Magento Community
Magento Community
Magento Community
 
quantumm
Jr. Member
 
Total Posts:  10
Joined:  2008-09-04
 

Guys,

I made a quick fix for this situation of duplicate reviews appearing on the reviews page… and I’m not even a programmer.  My goal was to also show product reviews on the product page but I also ran into the duplicate reviews appearing on the actual reviews page.

After finding out that it’s impossible to simply copy and paste the code from the review/product/view/list.phtml file (and being very frustrated about this) into the product view.phtml page, I tried used the code in post #9 of this thread to add the reviews to my product pages in view.html after the “Additional information” section and then fiddled with some formatting.

This worked but provided two sets of the same reviews on the actual review page.

So then I went back into the list.phtml page and commented out everything from just before the first call to get the toolbar to just after the second call to get the toolbar (I want every possible review to show up on this page, so why limit it to 10/20 per page?).

Now on the product page the reviews are showing and on the reviews page the same reviews show only once, while the form at the bottom shows up as it should.

Now if anyone can tell me how to isolate just the stars part of the ratings then that would great.

QM

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top