Johnny
Johnny

Reputation: 11

looking to show product reviews in sidebar on product page magento

I'm looking to show the most recent reviews for a product (maybe 3 or 4) in the sidebar on that products page in magento.

Showing the first 10 or 15 words of the review, the star bar and a link to the reviews page to see all the reviews..

any advice or pointers greatly appreciated,

Thanks,

Johnny

Upvotes: 1

Views: 3903

Answers (2)

Strange_76
Strange_76

Reputation: 66

As ElGabby said, creating a extension would be the way to go.

But you can do this by editing your current layout.

Go to the file catalog.xml in /app/design/frontend/default/[your theme]/layout/ or /app/design/frontend/base/[your theme]/layout/

find the section:

<catalog_product_view>

in there you proberly have a section like:

<reference name="right">

in that section add:

<block type="review/product_view" name="right.rewiev" template="review/rightbar.phtml" />

the section in my example look like this:

<reference name="right">
        <block type="review/product_view" name="right.rewiev" template="review/rightbar.phtml" />
        <block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
    </reference>

save the file and create a new file in: /app/design/frontend/default/[your theme]/design/review/rightbar.phtml

content of that file would be something like:

<?php $collection = $this->getReviewsCollection(); ?>
<?php if(count($collection) > 0):?>
<?php foreach ($collection as $rating):?>

    <?php echo $rating->title //title of the rewiev?>

    <?php echo $rating->detail //content of the rewiev?>
    <?php echo $rating->created_at //data rewiev is created?>
<?php endforeach;?>
<?php endif;?>

Upvotes: 4

Gabriel Spiteri
Gabriel Spiteri

Reputation: 4978

  • I would create an extension.
  • Using layout.xml place your block that should extend core/template block in left/right sidebar of the product page
  • Within that block class you should have methods that will retrieve from the database the reviews you wish to display. So say for instance you would need a method getReviews()
  • In the template call $this->getReviews() and iterate the result and display the reviews as you would like. The star bar might be a bit of a hassle but if you look at other template files where they are used you should be able to get the gist of it :)

HTH :)

Upvotes: 1

Related Questions