2

i added one customer programmatically and send mail to that customer for new password and also in admin side i found that customer but when customer try to login with email id and password got error 'Invalid login or password' here is my code what is problem with this?

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 = 'test@testemail.com';  // 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){

}
  • check the website_id in customer_entity table. what are the value of that? – Qaisar Satti Jul 2 '15 at 9:03
  • website_id is 1 – mit patel Jul 2 '15 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.