Wednesday, January 4, 2012

Getting the reviews page URL for a product in the product page sidebar

Adding the Review url in your customization page
For example
Since it is a new block that is needed, you need new template file.

Add:
app/design/frontend/base/default/template/review/sidebar.phtml

Enter into it something like:
 <div class="block block-reviews">
    <div class="block-title">
        <strong><span>Reviews</span></strong>
    </div>
    <div class="block-content">
    <p><a href="<?php echo $this->getNewReview($this->getProductId()) ?>">NewReview</a></p>
    </div>
</div>



Edit app/code/core/Mage/Review/Block/Product/View/List.php and add the helper URL function before the class closing brace:

    public function getNewReview($id)
    {
      return Mage::getUrl('review/product/list', array('id'=> $id));
    }

Now sort out your layout XML add to the reference left block or reference right, whatever, for the product page directives:

<block type="review/product_view_list" name="review_sidebar" as="newreview" template="review/sidebar.phtml"/>

That gets you the link you wanted, in a nice sidebar block with some stuff you can CSS to. Copy it over to your main theme. You can take what you want from the list.phtml template I pointed you towards earlier
 and do your own code to summarize your reviews or say something else if you have no reviews.

Note :You can use this code to add in the Product page also to add the Reviewbutton image

No comments:

Post a Comment

Thankyou for your Comments

LinkWithin

Blog has moved, searching new blog...