0

Consider the following code

$customer_email = "customer@example.com";
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($customer_email);

When looking through Mage_Customer_Model_Customer I could not find a loadByEmail method anywhere in it's inheritance chain. Then I looked at it's resource model, Mage_Customer_Model_Resource_Customer, and there it was.

My question is: how is it possible, that I load the model itself and get access to this method through the $customer_email variable?

  • I guess this question should be downvoted, so that noone gets tricked by it or closed or whatever. – dsplynm Nov 29 '13 at 9:53
0

I think you missed something. The method loadByEmail exists in the Mage_Customer_Model_Customer class: For Magento 1.7.0.2 it starts at line 180 and looks like this:

public function loadByEmail($customerEmail)
{
    $this->_getResource()->loadByEmail($this, $customerEmail);
    return $this;
}

It's just a wrapper for Mage_Customer_Model_Resource_Customer::loadByEmail but it exists.

  • I feel so embarrassed. :D Thank you, you are right! I guess I should have used Ctrl + F. – dsplynm Nov 29 '13 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.