0

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.

0

1 Answer 1

1

You 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
    .......