Question

I recently upgrading from magento 1.5 to 1.8, after upgrading "add your review" link return a URL like /review/product/list/id/250/#review-form. this URL show up a 2 col-right template where my page is 2 col-left design....before upgrading I use below method to show review on product view page.

I add below code before closing of "catalog_product_view" handle in catalog.xml.

<block type="review/product_view_list" name="product.info.product_additional_data" as="product_review" template="review/product/view/list.phtml">
                <block type="review/form" name="product.review.form" as="review_form"/>
            </block> 

then in view.phtml under catalog/product add a call

<?php echo $this->getChildHtml('product_review') ?> 

Every thing is fine in version 1.5 and when clicking "add your review" link, it return URl like www.mystore/product URL|#review-form, (this is different from version 1.8), so the display screen just jump to position of page defined by ID "review-form" on the same page instead of new URL like version 1.8 does..

I have checked "add your review" link was generated by function "getReviewsSummaryHtml" which is not changed from 1.5 to 1.8. also nothing changed in review.xml from 1.5 to 1.8. so I am getting lost.

my 1.5 version was created by other developer, may be some thing has to be done some where else before using above method to show review on product page....why the same function getReviewsSummaryHtml returning different URL which code look same from 1.5 to 1.8?

Was it helpful?

Solution

I have found answer. under my 1.5 theme, there is a template/review/helper/summary.phtml which is eventually called by getReviewSummaryHtml function and overridding its base file. with below code

 <p class="rating-links">
        <a href="#customer-reviews"><?php echo $this->__('%d Review(s)', $this->getReviewsCount()) ?></a>
        <span class="separator">|</span>
        <a href="#review-form"><?php echo $this->__('Add Your Review') ?></a>
    </p>

it assign a direct ID to respective link and jump to review portion on the product view page rather than load a review/product/list page in base design. I did not copy that summary.phtml file into my theme after upgrading.... hope this help those using above method to show review on product view page...

OTHER TIPS

I had simmilar problem on Magento2, in my case it was diffrent name for custom tabs and had to override file

vendor/magento/module-review/view/frontend/web/js/process-reviews.js

$(function () {
        $('.product-info-main .reviews-actions a').click(function (event) {
            var acnchor;

            event.preventDefault();
            acnchor = $(this).attr('href').replace(/^.*?(#|$)/, '');
            $('.product.data.items [data-role="content"]').each(function (index) { //eslint-disable-line
                if (this.id == 'smarttabs.reviews.tab') {
                    $('.product.data.items').tabs('activate', index);
                    $('html, body').animate({
                        scrollTop: $('#' + acnchor).offset().top - 50
                    }, 300);
                }
            });
        });
    });

Maybe it will help someone :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top