I am writing a script that automatically imports users into magento. Here is a code snippet:
$customer = Mage::getModel("customer/customer");
$customer->website_id = $websiteId;
$customer->setStore($store);
$customer->loadByEmail($riga[10]);
echo "Importo ".$data[0]."\n";
echo " email :".$data[10]."\n";
$customer->setTaxvat($data[7]);
$customer->lastname = $lastname;
$customer->email = $data[10];
$customer->password_hash = md5($data[0]);
$customer->save();
The problem is that the users are created as "not confirmed", while I would like them to be "confirmed".
I tried with:
$customer->setConfirmation('1');
before the save, but it didn't work. Does anybody know how to confirm the user?
Thanks!
I think setConfirmation()
is waiting for a confirmation key. Try passing null
and I think it will work?
Just to clarify:
$customer->save();
$customer->setConfirmation(null);
$customer->save();
Should force confirmation.
When I created accounts, they were already confirmed, but they were disabled! This fixed it:
$customer->save();
$customer->setConfirmation(null);
$customer->setStatus(1);
$customer->save();
Saving the entire model is expensive. You can save only the confirmation attribute which is very fast:
$customer->setConfirmation(NULL);
$customer->getResource()->saveAttribute($customer, 'confirmation');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With