如何在 Magento 中以编程方式确认用户?
我正在编写一个自动将用户导入到 magento 的脚本。 这是一个代码片段:
$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();
问题是用户被创建为“未确认”,而我希望他们被“确认”。
我在保存之前尝试过:
$customer->setConfirmation('1');
但没有成功。有人知道如何确认用户吗?
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为
setConfirmation()
正在等待确认键。尝试传递null
我认为它会起作用吗?只是为了澄清:
应该强制确认。
I think
setConfirmation()
is waiting for a confirmation key. Try passingnull
and I think it will work?Just to clarify:
Should force confirmation.
当我创建帐户时,它们已经被确认,但它们被禁用了!这修复了它:
When I created accounts, they were already confirmed, but they were disabled! This fixed it:
保存整个模型的成本很高。您可以只保存确认属性,速度非常快:
Saving the entire model is expensive. You can save only the confirmation attribute which is very fast: