I was looking for a solution to put the star rating element of a product in Magento on any given location. As most of you know, you can simply display the star rating element of a product (you know, the one with the five stars on a row) on a template like a product detail page or product list. But what if you have a product displayed elsewhere else and you just need to display the five stars without having access to the getReviewsSummaryHtml()
-function?
Inchoo already covered an interesting article about how to get the summary information anywhere, but I am solely interested in the five-star element. So, how can we achieve this? Well, here is how:
1 2 |
$reviewHelper = $this->getLayout()->createBlock('review/helper'); echo $reviewHelper->getSummaryHtml($loaded_product, 'short', false); |
Easy isn’t it?
Visitors give this article an average rating of -8,399.8 out of 5.
How would you rate this article?
★ ★ ★ ★ ★
Handige tip, ik wacht met smart op meer !
What file are you editing ?
Thanks Again
No file in particular. As the article stated, you can put the star rating element anywhere. So as long as you have a phtml file with a loaded product ($loaded_product in this example), you can use this code.
Ooooo… It’s working…. Thanks a lot!!!!
Great – working first time, thank you. Saved me a load of time