考虑以下代码

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

查看mage_customer_model_customer时,我找不到其继承链中任何地方的LoadByemail方法。然后,我查看了它的资源模型,mage_customer_model_resource_customer,就在那里。

我的问题是:如何加载模型本身并通过$ Custome_email变量访问此方法?

有帮助吗?

解决方案

我想你错过了一些东西。方法 loadByEmail 存在于 Mage_Customer_Model_Customer 课程:对于Magento 1.7.0.2,它从第180行开始,看起来像这样:

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

这只是一个包装纸 Mage_Customer_Model_Resource_Customer::loadByEmail 但是它存在。

许可以下: CC-BY-SA归因
scroll top