Magento: Check if customer already exist or not
When trying to add new user programatically, you will need to first check whether the customer is already registered or not in the system. For that, email address is required, as Magento uses email address for login purposes.
Below is the code which checks if customer is already there in the database, with some particular website id if any.
protected function _customerExists($email, $websiteId = null) | |
{ | |
$customer = Mage::getModel('customer/customer'); | |
if ($websiteId) { | |
$customer->setWebsiteId($websiteId); | |
} | |
$customer->loadByEmail($email); | |
if ($customer->getId()) { | |
return $customer; | |
} | |
return false; | |
} |
3 Comments
Leave a comment
Welcome to my Blog
Certifications
Honor
Recognition
Contributions
Categories
- Apache (2)
- ChatGPT (1)
- Domain name (2)
- eCommerce (2)
- htaccess (1)
- Humor (3)
- Instagram API (1)
- jQuery (4)
- JSON (1)
- Linux (10)
- Magento (142)
- Magento admin (58)
- Magento Certification (5)
- Magento error (13)
- Magento frontend (68)
- Magento Imagine (2)
- Magento Interview (5)
- Magento Master (2)
- Magento2 (10)
- Mobile (1)
- MySQL (7)
- OpenAI (1)
- OroCRM (2)
- Performance (2)
- PHP (8)
- Prototype JS (3)
- Security (4)
- Wordpress (3)
- XML (2)
Tag Cloud
500 internal server error admin answers attribute bug category checkbox checkout cookie customer difference domain name EAV error event extension interview invoice jquery linux magento magento2 magento admin magento error magento interview questions magento orm mysql observer order pinterest product products questions redirect register remove script session simplexml to array state status study guide tax url wordpress
Hello!
I found your blog while searching for a means to check a guest email address against the existing customer database in Magento. Any insight you can offer would be appreciated.
What I am trying to do is have the one page checkout form compare the email address entered for a guest order against the registered customer database and alert the customer that they already have an account and ask them if they would like to login before completing their order.
Do you know if possible and/or if a solution already exists in the form of a 3rd party extension?
Thank you for your time.
You need to fire ajax, or use already method which is fired, and check if customer with same address is there in DB or not. I think it should not be a big deal. And open some fancy popup saying that you are already a member, would you like to login before proceeding your order? (also provide forgot password link). If customer clicks on login before proceeding order, just close the popup and focus the cursor on login form.
I think this should help you in building it yourself, I don’t know if there are any extensions that does this.
In Magento 2, How can I check if an email address is real or fake in real life?