Do You Want to Learn Marketing or Coding? Do You Want to Learn Marketing or Coding?

Magento Show Latest Review on Product Page

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

Want to show the latest product review on your product page? It is simple add the following

<?php
                $productId = $this->getProduct()->getId(); 
                $reviews = Mage::getModel('review/review')
                    ->getResourceCollection()
                    ->addStoreFilter(Mage::app()->getStore()->getId())
                    ->addEntityFilter('product', $productId)
                    ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                    ->setDateOrder()
                    ->addRateVotes();
                $ratings = array();
                if (count($reviews) > 0) {
                    $x = 1;
                ?>
                    <div class="product-review-template">
                        <h2>Latest Review</h2>
                        <div class="single-review-template">
                            <?php 
                                foreach ($reviews->getItems() as $review) {
                                    echo '<p>'.$review->getDetail().'</p>';
                                    echo '<p><span class="author">'.$review->getNickname().'</span>';
                                    foreach( $review->getRatingVotes() as $vote ) {
                                        echo '<span class="stars">'.$vote->getRatingCode().' - '.$vote->getPercent().'</span></p>';
                                    }
                                    if($x == 1){ break; }
                                }
                            ?>
                        </div>
                    </div>
<?php } ?>

I Really Need

Reviewing nerdy stuff is expensive.

Consider clicking on this ad & buying that item you REALLY wanted from Amazon.

It helps a ton!

Leave Your Thoughts