I've come across this really, really odd error. For old customers, the $customer->loadByEmail function loads perfectly fine as expected. However for new customer accounts, it returns empty as if there is no customer. However, there definitely is a customer. I can see that in the admin and all of the fields in the database. I can barely see any differences between old and new in terms of what data is there.
The website scope shouldn't be an issue - it's set correctly and even when I manually set it (i.e. $customer->setWebsiteId(1)) the same result occurs.
Why would this function think a customer does not exist?
Thanks in advance
As per Magento there is no particular line drawn between an old and a new customer as such as far as i know - so, what do you mean by "new customer" exactly?
Is it one that has just registered and never logged in i.e. waiting for confirmation, or maybe just has logged in for the very first time or has never placed any orders?
Also, some background about how/where you call $customer->loadByEmail() would be helpful. Verified that you're actually passing a mail address to load?
Thanks for you reply @cfarnleitner
What I mean is that there was a point in time when things went wrong. Customer accounts created before that time can still login fine; only accounts created afterwards are having issues.
I was calling $customer->loadByEmail() in a random location - I thought it should work since that function only requires an email and the model. Specifically, I believe authenication is failing because the loadByEmail() is called at line 176 of app/code/core/Mage/Customer/Model/Customer.php, and is failing to load.
I can confirm that the email string is being passed into the function.
Another hint: I created new customer data in a fresh install of Magento and swapped it into the problematic site's DB. The account that I created on the fresh install could login just fine after being imported into the problematic site, but any new accounts created on the problematic site remain... problematic
Now that's interesting.. but unfortunately it seems quite difficult to figure out where exactly things go wrong without seeing some relevant code.
However, let's try it based on some random thoughts:
- in your DB, is there a record in the table 'customer_entity' for the mail addresses in question?
- if so, as it sounds you have quite a good idea about when all this started, so can you see any relevant differences about a customers record that can login compared to one that can not login?
- do your customers experience the same problem even when their account got created in backend?
- if no (quite sure about that), i think we got a first hint - in this case I'd first of all check for the formkeys in your registration template (app/design/frontend/*/*/template/customer/form/register.phtml).
There must be something like
<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
within the <form> (assuming you got a more or less up-to-date version of Magento)
you may as well want to check what data is sent to the createPostAction() in app/code/core/Mage/Customer/controllers/AccountController.php
Something like this added at the beginning of that function should push the params array to your var/log/system.log:
If that would not bring any insights you may want to start disabling modules from within app/etc/modules (set <active>true</active> to <active>false</active>) for those that seem to be related to customers.