- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2019
07:36 AM
06-26-2019
07:36 AM
Re: Add new customer attribute
@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.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2019
07:54 AM
06-26-2019
07:54 AM
Re: Add new customer attribute
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!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2019
08:07 AM
06-26-2019
08:07 AM
Re: Add new customer attribute
@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.
- « Previous
-
- 1
- 2
- Next »