2016-03-11 38 views
0

我需要檢索電子郵件客戶ID檢索客戶ID,我已經試過這樣:Magento的getmodel不工作,我需要通過電子郵件

$collection = mage::getModel('customer/customer')->getCollection() 
    ->addAttributeToSelect('customer_id') 
    ->addAttributeToFilter('email', '[email protected]') 
    ->addAttributeToSort('customer_id', 'ASC'); 
echo (string)$collection->getSelect(); 

,但它始終返回500錯誤; 有什麼問題?

有沒有辦法通過電子郵件檢索客戶信息?

回答

0

請使用標準功能的Magento:

$customerEmail = '[email protected]'; 

$客戶=法師:: getModel('顧客/客戶) - > loadByEmail($ customerEmail); $ customerId = $ customer-> getId();

+0

我試過了,但出現錯誤: – user1851384

+0

加載資源失敗:服務器響應狀態爲500(內部服務器錯誤) {「readyState」:4,「responseText」:「」,「status」:500 ,「statusText」:「內部服務器錯誤」} – user1851384

+0

我把它放在根文件夾中的getCustomer.php ..我錯了嗎?在哪裏放置php視圖文件? – user1851384