Magento性别客户系列
我已尝试使用自定义模块创建新客户帐户。我需要在创建客户帐户时存储性别。这是我试图储存性别的收集品Magento性别客户系列,magento,Magento,我已尝试使用自定义模块创建新客户帐户。我需要在创建客户帐户时存储性别。这是我试图储存性别的收集品 $customer = Mage::getModel('customer/customer')->setId(null); $customer->setData('firstname', $data['first_name']); $customer->setData('lastname', $data['last_name']);
$customer = Mage::getModel('customer/customer')->setId(null);
$customer->setData('firstname', $data['first_name']);
$customer->setData('lastname', $data['last_name']);
$customer->setData('email', $data['email']);
$customer->setData('gender', $data['gender']);
$customer->setData('is_active', 1);
$customer->setData('confirmation', null);
$customer->setConfirmation(null);
$customer->getGroupId();
$customer->save();
在此集合中,名字、姓氏和电子邮件正确保存在customer表中。
但是性别信息没有保存在客户表中?除了两个小错误,双重确认设置,过时的getGroupId这应该可以工作 我猜您在$data['SEXT']中使用了错误的性别选项id 尝试使用固定的性别值来检查:
$customer = Mage::getModel('customer/customer')
->setFirstname('John')
->setLastname('Doe')
->setEmail('51zv52zg@example.com')
->setGender(
Mage::getResourceModel('customer/customer')
->getAttribute('gender')
->getSource()
->getOptionId('Female')
)
->setIsActive(1)
->setConfirmation(null)
->save();
除了两个小错误,双重确认设置,过时的getGroupId,这应该可以工作 我猜您在$data['SEXT']中使用了错误的性别选项id 尝试使用固定的性别值来检查:
$customer = Mage::getModel('customer/customer')
->setFirstname('John')
->setLastname('Doe')
->setEmail('51zv52zg@example.com')
->setGender(
Mage::getResourceModel('customer/customer')
->getAttribute('gender')
->getSource()
->getOptionId('Female')
)
->setIsActive(1)
->setConfirmation(null)
->save();