如何以编程方式确认Magento中的用户?
我正在编写一个脚本,自动将用户导入magento。 以下是一段代码片段:如何以编程方式确认Magento中的用户?,magento,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 :".$dat
$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');
在保存之前,但它不起作用。有人知道如何确认用户吗
谢谢 我想
setConfirmation()
正在等待确认键。尝试传递null
,我认为它会起作用吗
我想澄清一下:
$customer->save();
$customer->setConfirmation(null);
$customer->save();
应该强制确认。当我创建帐户时,它们已被确认,但已被禁用!这修正了它:
$customer->save();
$customer->setConfirmation(null);
$customer->setStatus(1);
$customer->save();
保存整个模型是昂贵的。您只能保存非常快速的确认属性:
$customer->setConfirmation(NULL);
$customer->getResource()->saveAttribute($customer, 'confirmation');
就是这样。:-)我想强调的是,正如melee所指出的,在创建客户时,在设置确认键之前和之后进行保存是很重要的。回答得很好,不过值得阅读现有的答案,看看问题是否已经以类似的方式得到解决。customer上似乎没有“status”属性,因此setStatus(1)毫无意义。