2015-07-02 133 views
0

我以編程方式添加了一個客戶,併發送郵件給該客戶以獲取新密碼,並且在管理員端我發現該客戶,但是當客戶嘗試使用電子郵件ID和密碼登錄時出現錯誤'Invalid登錄或密碼' 這裏是我的代碼 這是什麼問題?magento的客戶無效的登錄名或密碼錯誤

define('MAGENTO_ROOT', getcwd()); 
$mageFilename = MAGENTO_ROOT . '/app/Mage.php'; 
require_once $mageFilename; 
Mage::init(); 
Mage::setIsDeveloperMode(true); 
ini_set('memory_limit', '-1'); //for unlimited memory being more trickey 
ini_set('display_errors', 1); 
Varien_Profiler::enable(); 
umask(0); 
Mage::app('default'); 

$customer_email = '[email protected]'; // email adress that will pass by the questionaire 
$customer_fname = 'test_firstname';  // we can set a tempory firstname here 
$customer_lname = 'test_lastname';  // we can set a tempory lastname here 
$passwordLength = 10;     // the lenght of autogenerated password 

$customer = Mage::getModel('customer/customer'); 
$customer->setWebsiteId(Mage::app()->getWebsite()->getId()); 
$customer->loadByEmail($customer_email); 
/* 
* Check if the email exist on the system. 
* If YES, it will not create a user account. 
*/ 

if(!$customer->getId()) { 

    //setting data such as email, firstname, lastname, and password 

    $customer->setEmail($customer_email); 
    $customer->setFirstname($customer_fname); 
    $customer->setLastname($customer_lname); 
    $customer->setPassword($customer->generatePassword($passwordLength)); 

} 
try{ 
    //the save the data and send the new account email. 
    $customer->save(); 
    $customer->setConfirmation(null); 
    $customer->save(); 
    $customer->sendNewAccountEmail(); 
} 

catch(Exception $ex){ 

} 

先感謝....

回答

0

我想這不是客戶自動設置爲活動。你可以通過在你的db上運行這個查詢來進行確認;

SELECT * FROM customer_entity WHERE email = '[email protected]' 

書中有一欄叫「IS_ACTIVE」,幾乎可以肯定是設置爲0表示無。

在您創建客戶的腳本中添加此項,然後保存;

$customer->setIsActive(1); 
相關問題