I am trying to add 2 customer attribute fields in my Magento registration form.
The input names are the same in the register.phtml
as in the install-1.0.0.php
file. However I think there is something wrong in the installer file, because only the first attribute is saved (is_privacy_statement
).
Here is my code from the installer file:
$installer = $this;
$installer->startSetup();
$installer->addAttribute("customer", "is_privacy_statement", array(
"type" => "int",
"label" => "Privacy Statement",
"input" => "checkbox",
"position" => 120,
"required" => true,
"is_system" => 0
));
$installer->addAttribute("customer", "is_general_terms", array(
"type" => "int",
"label" => "General Terms",
"input" => "checkbox",
"position" => 121,
"required" => true,
"is_system" => 0
));
$attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "is_privacy_statement", "is_general_terms");
$used_in_forms=array();
$used_in_forms[]="adminhtml_customer";
$used_in_forms[]="checkout_register";
$used_in_forms[]="customer_account_create";
$used_in_forms[]="customer_account_edit";
$attribute->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_user_defined", 1)
->setData("is_visible", 1);
$attribute->save();
$installer->endSetup();
I have no idea why is not saved the second attribute too.
$attribute1 = Mage::getSingleton("eav/config")->getAttribute("customer", "is_privacy_statement"); $attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "is_general_terms");
because thatgetAttribute
method have 2 param only.