Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 3
Redirect customer login to the website they belong to
 
ericp
Jr. Member
 
Total Posts:  17
Joined:  2009-06-15
 

I’ve set up Magento with 3 websites like this:
Main website: magento.dev
Member 1 website: magento.dev/member1
Member 2 website:magento.dev/member2

I did this so, different members can have different prices for the same products.
The problem is, I don’t want to tell member1 that they need to login to magento.dev/member1. I’d rather have everyone log into the main website:  magento.dev and detect which website they are a member of and redirect them after login to the correct website.

My first thoughts were to create a separate login page that all the websites go to, but is there another way?

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
ericp
Jr. Member
 
Total Posts:  17
Joined:  2009-06-15
 

I’ve managed to do a redirect to the proper website directory when they try and login to the main website, but it just takes them to the login form and does not log them in. I need to figure out how to log them in to the correct website and redirect them. Perhaps using cURL?

In app/code/core/Mage/Customer/controller/AccountController.php

At the bottom of this function loginPostAction() I wrote this code:

$code='';
        
$write Mage::getSingleton('core/resource')->getConnection('core_write');
        
$readresult=$write->query('select * from customer_entity LEFT JOIN core_website
                ON customer_entity.website_id=core_website.website_id
                WHERE email= \''.$login['
username'].'\' ');

         while (
$row $readresult->fetch() ) {
                    $increment_id
=$row['increment_id'];
                    
$website_id=$row['website_id'];
                    
$code=$row['code'];
    
}
         
         
        
// now rewrite the url
        
if($code=='base'){
            $url
=$_SESSION['customer_base']['before_auth_url'];

        
}else{

            $url
='http://magento.dev/'.$code.'/customer/account/login/';
        
}
        

        $this
->_redirectUrl($url);
 
Magento Community Magento Community
Magento Community
Magento Community
 
Twin Signals
Jr. Member
 
Total Posts:  12
Joined:  2010-04-26
 

Did you find a solution to this? I am looking for this exact functionality!

Rich

 
Magento Community Magento Community
Magento Community
Magento Community
 
joejoe
Sr. Member
 
Total Posts:  102
Joined:  2011-01-21
 

Also looking for this… there is an extension which purports to solve this but the connect package doesn’t seem to work, plus it doesn’t say it supports 1.5etc

 
Magento Community Magento Community
Magento Community
Magento Community
 
jaleko
Jr. Member
 
Avatar
Total Posts:  19
Joined:  2010-05-18
Italy
 

I have write this extension
http://www.magentocommerce.com/extension/specs/5736/redirect_customer_login_to_assigned_website

Bye

 
Magento Community Magento Community
Magento Community
Magento Community
 
joejoe
Sr. Member
 
Total Posts:  102
Joined:  2011-01-21
 

Yes, I saw your extension before but when you try and put it into magento connect you get:

“community/Redirect_customer_login_to_assigned_website: Version for ‘Redirect_customer_login_to_assigned_website’ was not detected”

Is that because it doesn’t work for 1.5? (I am using 1.5)

Thanks for your reply though!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jaleko
Jr. Member
 
Avatar
Total Posts:  19
Joined:  2010-05-18
Italy
 
joejoe - 01 April 2011 05:14 AM

Yes, I saw your extension before but when you try and put it into magento connect you get:

“community/Redirect_customer_login_to_assigned_website: Version for ‘Redirect_customer_login_to_assigned_website’ was not detected”

Is that because it doesn’t work for 1.5? (I am using 1.5)

Thanks for your reply though!

You used
http://connect20.magentocommerce.com/community/Redirect_customer_login_to_assigned_website
or
magento-community/Redirect_customer_login_to_assigned_website?

Try
http://connect20.magentocommerce.com/community/Redirect_customer_login_to_assigned_website

Bye grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
joejoe
Sr. Member
 
Total Posts:  102
Joined:  2011-01-21
 

I used:

http://connect20.magentocommerce.com/community/Redirect_customer_login_to_assigned_website

Still this:

“community/Redirect_customer_login_to_assigned_website: Version for ‘Redirect_customer_login_to_assigned_website’ was not detected”

...and I’ve tried it in other running installations of 1.5 that I have.

All my other extensions work fine and installed fine… any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
jaleko
Jr. Member
 
Avatar
Total Posts:  19
Joined:  2010-05-18
Italy
 

Try to upload app directory in your magento root.

Bye

File Attachments
redirect_customer_login_to_assigned_website-1.0.2.zip  (File Size: 6KB - Downloads: 132)
 
Magento Community Magento Community
Magento Community
Magento Community
 
joejoe
Sr. Member
 
Total Posts:  102
Joined:  2011-01-21
 

Uploaded… anything else I need to do after that?

Redirect not happening yet… :/

EDIT: Also tried it on another installation, still not working… I’ve re-indexed and flushed cache if that helps :D

It may be that I am missing something obvious… but I uploaded, indexed, flushed cache and the redirect doesn’t happen.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jaleko
Jr. Member
 
Avatar
Total Posts:  19
Joined:  2010-05-18
Italy
 

Configure websites base url (see pictures).
Your domain must have an alias domain

Add in .htaccess

<IfModule mod_setenvif.c>
SetEnvIf Host www\.shop\.it MAGE_RUN_CODE=b2c_ita
SetEnvIf Host www\
.shop\.it MAGE_RUN_TYPE=store

SetEnvIf Host b2b\
.shop\.it MAGE_RUN_CODE=b2b_ita
SetEnvIf Host b2b\
.shop\.it MAGE_RUN_TYPE=store
</IfModule>

\ are required.

b2b_ita and b2c_ita are store code set in System > Manage Stores

Image Attachments
b2c.pngb2b.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
jaleko
Jr. Member
 
Avatar
Total Posts:  19
Joined:  2010-05-18
Italy
 

I have try to install my extension on 1.5.0.1.

To resolve you need to click settings in magento connect manager and change the preferred state to beta.

It works for me.

Bye

 
Magento Community Magento Community
Magento Community
Magento Community
 
joejoe
Sr. Member
 
Total Posts:  102
Joined:  2011-01-21
 

- Base URLs for the 6 or so websites I am running are already configured (the websites all work independently)…

- What do you mean by alias domain? I am running the websites from directories at the main domain e.g.

main installation/base website: magento.com
website 1: magento.com/website1
website 2: magento.com/website2
website 3: magento.com/website3
etc…

These all work, I just want to redirect all customers from base install at magento.com to their assigned website.

- Amended my htaccess to:

<IfModule mod_setenvif.c>
SetEnvIf Host www\\.magento\\.com MAGE_RUN_CODE=base
SetEnvIf Host www\\.magento\\.com MAGE_RUN_TYPE=website

SetEnvIf Host www\\.magento\\.com MAGE_RUN_CODE=website1
SetEnvIf Host www\\.magento\\.com MAGE_RUN_TYPE=website
</IfModule>

- So, if this is all correct then where do I set my install to beta and is this a good idea? Is it \’safe\’?

I guess that\’s it...?

 
Magento Community Magento Community
Magento Community
Magento Community
 
sotirios
Jr. Member
 
Total Posts:  13
Joined:  2011-02-19
 

I need exact the same functionality.

I will try to install beta version of this extension, and i will write back.

grin

UPDATE:

Indeed extension does work! I installed it, in a Magento ver. 1.5.0.1 installation.

I did this after installing it: System > Configuration > Customers > Customer Configuration > Account Sharing Options > Share Customer Accounts must be set Global

and everything worked.

I logged in from mydomain.com and redirected to mydomain.com/wholeshale (the site that is associated with my account).

I didn’t change anything in .htaccess.

Thanks a lot

 
Magento Community Magento Community
Magento Community
Magento Community
 
joejoe
Sr. Member
 
Total Posts:  102
Joined:  2011-01-21
 

Magento redirects by default in the \’share customer accounts\’ mode… the extension is doing nothing in your case I don\’t think. This is what magento does anyway. The extension is supposed to redirect in non-sharing mode.

Jaleko… can you confirm this?

I still don\’t know where to set my install to beta… I\’ll keep looking :S

- Missed your bit about connect, I’ll try that and report back…

 
Magento Community Magento Community
Magento Community
Magento Community
 
joejoe
Sr. Member
 
Total Posts:  102
Joined:  2011-01-21
 

OK - Installed this extension fine in beta mode… BUT…

I notice you require customer sharing to be set to global…

Well, in 1.5, re-direct already happens on login when customer accounts are shared globally!

So this extension doesn’t do anything...?

I need an extension that re-directs a customer to their assigned website from the main install login without sharing accounts (I don’t want a user of one website to be able to access another website).

Anyone who can help? I may be able to get a *small* budget for paid work on this…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 3