5

I am trying to show catalog prices only to logged in users. Following snippet works however it has two issues:

if(!Mage::helper('customer')->isLoggedIn()) {
Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl()); 

echo '<a href="'.Mage::getUrl('customer/account/login').'">Please Login to view prices</a>';

}

Issues:

1) If login credentials are incorrect, page redirects to previous page (on catalog page) and shows 'invalid login error'. Ideally, it should stay on the login page and should not redirect unless login is successful.

2) If user login is successful in first attempt, page redirects to catalog page. however, url contains port 8080. domain.com:8080/catalog/

Any fix for above issues?

or

Is it possible to have login on a popup on the catalog page?

1 Answer 1

2

Harry,first you need to check admin setting

Then goto admin>System>Configuration>Customer>

here find

Redirect Customer to Account Dashboard after Logging in setting make it NO

and

instead of using Mage::getUrl('customer/account/login');

used below code

Mage::helper('customer')->getLoginUrl();

Remove below code:

Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl());
1
  • Thank you for the response. However, when I entered wrong login details, page redirected to catalog page with the error 'Invalid Login' but it suppose to go back to product view page!? Not working! Again,
    – harry
    Commented Oct 23, 2014 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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