顧客モデルオブジェクトは、モデルリソースのLoadByEmailメソッドについてどのように知っていますか?

magento.stackexchange https://magento.stackexchange.com/questions/11326

  •  16-10-2019
  •  | 
  •  

質問

次のコードを検討してください

$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であることを見ました。

私の質問は、どのように可能ですか、私はモデル自体をロードし、$ customer_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帰属
所属していません magento.stackexchange
scroll top