1

My Magento installation will be split into 2 websites with different currencies and different prices (think: Canada/US), with identical products on both sites. Customers will be signed up to one website or the other, depending on their region.

How can I have a single login page that, after the customer logs in, takes her/him to whichever website he/she is signed up to?

As a side note, I am using the extension http://www.magentocommerce.com/magento-connect/private-sales-5.html so that the store is only visible to logged in users.

Also, I understand that Customers can be scoped globally in System > Configuration > Customer Configuration > Account Sharing Options but currently I have them set to Per Website. Will this setting help me?

2
  • Is it possible to have a customer who belong to both store, and if so which store would you like them to redirect to? Jun 17, 2015 at 18:29
  • ideally, no. Our customers are targeted towards specific markets so we cannot mix them. But if we have to select 'Global' and solve the issue some other way, that will work too.
    – Anthony
    Jun 17, 2015 at 21:02

2 Answers 2

3

Take a look at

loginPostAction() in app/code/core/Mage/Customer/controllers/AccountController.php login() in app/code/core/Mage/Customer/Model/Session.php

To log in a customer we need to do

    /** @var $customer Mage_Customer_Model_Customer */
    $customer = Mage::getModel('customer/customer')
        ->setWebsiteId(Mage::app()->getStore()->getWebsiteId());

    if ($customer->authenticate($username, $password)) {
        $this->setCustomerAsLoggedIn($customer);
        $this->renewSession();
        return true;
    }

However, we currently do NOT know which website the customer belong to and by default it is hardcoded to the current website.

So, try creating a custom module that will handle the login using the following logic

  1. Search customer_entity table (which store website_id and email address)to see if the email address exist (check to make sure only one entry exist )
  2. If email exist we get the website id
  3. Set the website id and redirect to the correct store.
1

Thanks to R.S for the interesting answer. However being that we need to keep things simple at our small company, we are going to undertake a different solution.

We will keep Magento at a "one website" configuration, and we will be using the CustomerGroupsPrice extension by WebTex to put our customers on separate price lists. All our purchasing is done via purchase order, so our Magento installation doesn't even need a notion of currency.

Comments from more experienced Magento devs will be appreciated, as I am ok with PHP/Wordpress, but I don't even know how to make an extension yet (I haven't even learned MVC).

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.