I created a custom attribute for customer module using below install script:
<?php
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$installer->addAttribute("customer", "mobile", array(
"type" => "varchar",
"backend" => "",
"label" => "Mobile Number",
"input" => "text",
"source" => "",
"visible" => true,
"required" => false,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => "Mobile Number"
));
$attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "mobile");
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'mobile',
'999' //sort_order
);
$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";
//$used_in_forms[]="adminhtml_checkout";
$attribute->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100)
;
$attribute->save();
$installer->endSetup();
new mobile
attribute created in eav_attribute
table. But while retrieving in customer edit form using below, mobile
attribute is missing there.
<?php
Mage::log(print_r($this->getCustomer()->getData(), true), null, 'customer.log');
?>
Below is the output I got:
(
[entity_id] => 23
[entity_type_id] => 1
[attribute_set_id] => 0
[website_id] => 1
[email] => [email protected]
[group_id] => 1
[increment_id] =>
[store_id] => 1
[created_at] => 2015-10-18T11:56:26+04:00
[updated_at] => 2015-10-18 11:56:26
[is_active] => 1
[disable_auto_group_change] => 0
[created_in] => Default Store View
[firstname] => Anto
[lastname] => Jaskaran
[password_hash] => 7bda12fd6b2ecea227d55f088f5b653e:FBVp10XN6FZWBXZ8v0waWazWAw5KYreX
)