By default, Magento only supports mailbox logons, so we need to modify the code. The idea is that you can find your mailbox by entering your phone number and user name.
First you need to rewrite the controller, add the configuration file
<rewrite>
< module name _ controller _account>
<from><! [cdata[#^/customer/account/#]]></from>
<to>/icustomer/account/</to>
</Module Name _ Controller _account>
Now, you need to create a new accountcontroller.php controller in the Controller folder under your module, and then rewrite the inside Oh loginpostaction This method:
Public Function loginpostaction ()
{
if (! $this->_validateformkey ()) {
$this->_redirect (' */*/');
Return
}
if ($this->_getsession ()->isloggedin ()) {
$this->_redirect (' */*/');
Return
}
$session = $this->_getsession ();
if ($this->getrequest ()->ispost ()) {
$login = $this->getrequest ()->getpost (' login ');
$data = $login ["username"];
Phone number and user name login process
if (! ( int) ($DATA))
{
If the input is a character, through the username email query out
$read = Mage::getsingleton ("Core/resource")->getconnection (' Core_read ');
$sql = "SELECT * from ' customer_entity ' where username = ' {$data} '";
$result = $read->fetchrow ($sql);
$dataA = $result ["Email"];
$login [' username '] = $dataA;
}else
{
If you enter a number, you can check the email by phone number.
$read = Mage::getsingleton ("Core/resource")->getconnection (' Core_read ');
$sql = "SELECT * from ' customer_entity ' where Customer_mobile_number = ' {$data} '";
$result = $read->fetchrow ($sql);
$dataA = $result ["Email"];
$login [' username '] = $dataA;
}
if (!empty ($login [' username ']) &&!empty ($login [' password ']) {
try {
$session->login ($login [' username '], $login [' Password ']);
if ($session->getcustomer ()->getisjustconfirmed ()) {
$this->_welcomecustomer ($session->getcustomer (), true);
}
} catch (Mage_core_exception $e) {
Switch ($e->getcode ()) {
Case mage_customer_model_customer::exception_email_not_confirmed:
$value = $this->_gethelper (' Customer ')->getemailconfirmationurl ($login [' username ']);
$message = $this->_gethelper (' Customer ')->__ (' The account has not been confirmed. <a href= "%s" > click here </a> get confirmation email. ', $value);
Break
Case Mage_customer_model_customer::exception_invalid_email_or_password:
$message = $e->getmessage ();
Break
Default
$message = $e->getmessage ();
}
$session->adderror ($message);
$session->setusername ($login [' username ']);
} catch (Exception $e) {
Mage::logexception ($e); PA DSS violation:this Exception Log can disclose customer password
}
} else {
$session->adderror ($this->__ (' Username and password error '));
}
}
$this->_loginpostredirect ();
}
Only need to add an if judgment statement to the controller can be very simple to achieve the use of mobile phone number and user name login.
Magento for mobile and username login