如何在 Magento 中以编程方式确认用户?

发布于 2024-09-13 09:36:47 字数 635 浏览 3 评论 0原文

我正在编写一个自动将用户导入到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

唯憾梦倾城 2024-09-20 09:36:47

我认为 setConfirmation() 正在等待确认键。尝试传递 null 我认为它会起作用吗?

只是为了澄清:

$customer->save();
$customer->setConfirmation(null);
$customer->save();

应该强制确认。

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.

长亭外,古道边 2024-09-20 09:36:47

当我创建帐户时,它们已经被确认,但它们被禁用了!这修复了它:

$customer->save();
$customer->setConfirmation(null);
$customer->setStatus(1);
$customer->save();

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();
孤城病女 2024-09-20 09:36:47

保存整个模型的成本很高。您可以只保存确认属性,速度非常快:

$customer->setConfirmation(NULL);
$customer->getResource()->saveAttribute($customer, 'confirmation');

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');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文