Magento – Find if there are reviews or not in reviews/form.phtml

formsproductreview

Im trying to find out if there are reviews for the product the user is on within the review/form.phtml template file.

The idea is if the product has reviews give the review form a particular class to position it on the page, if the product doesn't have any reviews, don't change to class name and leave it where it is.

Does this make sense?

So my question is how to i retrieve amount of reviews for a product in the review/form.phtml file?

thanks

Edit

I have tried this statement:

<?php if( count( $this->getReviewsCollection() > 0 ) ): ?>
    <div class="form-add got-reviews-form">
<?php else: ?>
    <div class="form-add no-reviews-form">
<?php endif; ?>

This doesn't give me fatal errors which means its along the right tracks, but theres a big problem in the ract that it always returns true, so even if the product doesn't have reviews, i still get the

got-reviews-form

class. Any ideas why this could be?

Thanks

Best Answer

You have a typo in your code, bracket is in wrong place:

<?php if( count( $this->getReviewsCollection() > 0 ) ): ?>

It should be:

<?php if( count( $this->getReviewsCollection() ) > 0  ): ?>

However, it's better to use this code if you only want to check size of the collection:

<?php if( $this->getReviewsCollection()->getSize() > 0  ): ?>