Magento getmodel不起作用,我需要通过电子邮件检索客户ID

时间:2016-03-11 08:04:20

标签: magento

我需要通过电子邮件检索客户ID,我试过这样:

    $collection = mage::getModel('customer/customer')->getCollection()
   ->addAttributeToSelect('customer_id')
   ->addAttributeToFilter('email', 'costumeremail@gmail.com')
   ->addAttributeToSort('customer_id', 'ASC');
echo (string)$collection->getSelect();

但它总是返回错误500; 怎么了?

有没有办法通过电子邮件检索客户信息?

1 个答案:

答案 0 :(得分:0)

请使用标准功能magento:

$customerEmail = 'someemail@sample.com';

$ customer = Mage :: getModel('customer / customer') - > loadByEmail($ customerEmail); $ customerId = $ customer-> getId();