I am working on magento-1.9.
Here, the customer can login to my website by Email address only. But I need to login with phone number/email address. How I can do it?
Please any one can answer me.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityYou can do it this way, I hope you know how to override controller in your Custom module so I am not going into that part.
Override Mage_Customer_AccountController
to your local module and update loginPostAction
function with below code.
public function loginPostAction()
{
......
if ($this->getRequest()->isPost()) {
$login = $this->getRequest()->getPost('login');
// NEW CODE ADDED
$phoneNumber = $login['username'];
$customer = Mage::getResourceModel('customer/address_collection')
->addAttributeToSelect('telephone')
->addAttributeToFilter('telephone', $phoneNumber)
->getFirstItem()->getCustomer();
if ($customer !== false) {
$login['username'] = $customer->getEmail();
}else{
$login['username'] = $phoneNumber;
}
// NEW CODE COMPLETED
.......