@hanhoe
Good to know that it works for you.
Please accept as solutions which works for you, so it will help to others as well.
Hello @Vimal Kumar
just one more question:
when I want to add more as one attribute?
$customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, 'customer_number', [
'type' => 'varchar',
'label' => 'Account Number',
'input' => 'text',
'source' => '',
'required' => false,
'visible' => true,
'position' => 333,
'system' => false,
'backend' => ''
]);
$customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, 'phone_number', [
'type' => 'varchar',
'label' => 'Phone Number',
'input' => 'text',
'source' => '',
'required' => false,
'visible' => true,
'position' => 333,
'system' => false,
'backend' => ''
]);
$customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, 'mobile_number', [
'type' => 'varchar',
'label' => 'Mobile Number',
'input' => 'text',
'source' => '',
'required' => false,
'visible' => true,
'position' => 333,
'system' => false,
'backend' => ''
]);
Is this way correct? Updating of extension_attributes of course as well!
@hanhoe
Yes, it is fine.
But If you have installed module once and then you need to add more attributes then you should create a updateData.php instead of write code in installData.php and update the version in your module.xml file.
Then it will create only new attributes.
extension_attributes is also a best solution.