0

I'm using Magento 1.9 version.

I want to redirect the customer to the login page only when they click on the review button in the product view page and also redirect to the same product view page after login. But it redirects when I load product view page.

I have used this code:

if(Mage::getSingleton('customer/session')->isLoggedIn()){
//some stuff
}else{
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account'))
}
0

Try this code for redirect to login

if(! Mage::helper('customer')->isLoggedIn()){
        Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account/login'));
    }
0

If I understand you correctly, you don't want to allow customer to review as guest, since you said you want to redirect them to login page.

This is already built in magento. Go to System > Configuration > Catalog > Product Reviews and

set Allow Guests to Write Reviews to NO

This will also make sure that it will redirect to login page on "Review" click.

Hope this helps.

  • Thanks, @Adarsh. I want to allow guest to write a review, but as per my customization, when the user reads and clicks the review useful/not button, the redirect should be worked if they are not loggedIn. – Saravanan DS Sep 6 '16 at 7:13
0
public_html/app/design/frontend/default/THEME_NAME_HERE/template/review/product/view/list.phtml

loop where reviews are listed

PUT YOUR CODE AFTER THIS <h2><?php echo $this->__('Customer Reviews') ?></h2>

<?php if(Mage::getSingleton('customer/session')->isLoggedIn()){ ?>

put this one after

 <?php echo $this->getChildHtml('toolbar') ?>
 <?php }else{  ?>
       <a href="BASE URL HERE (Mage::getBaseUrl())/customer/account/login/"> <button type="button"> Please login  to view review </button>
        <?php 

} ?>

OR MAY BE YOU CAN USE REDIRECT HERE..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.