Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
attribute_user_defined_address_custom_attribute.php
Go to the documentation of this file.
1 <?php
7 $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class);
8 $model->setName(
9  'custom_attribute1'
10 )->setEntityTypeId(
11  2
12 )->setAttributeSetId(
13  2
14 )->setAttributeGroupId(
15  1
16 )->setFrontendInput(
17  'text'
18 )->setFrontendLabel(
19  'custom_attribute_frontend_label'
20 )->setIsUserDefined(
21  1
22 );
23 $model->save();
24 
25 $model2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class);
26 $model2->setName(
27  'custom_attribute2'
28 )->setEntityTypeId(
29  2
30 )->setAttributeSetId(
31  2
32 )->setAttributeGroupId(
33  1
34 )->setFrontendInput(
35  'text'
36 )->setFrontendLabel(
37  'custom_attribute_frontend_label'
38 )->setIsUserDefined(
39  1
40 );
41 $model2->save();
42 
45  \Magento\Customer\Setup\CustomerSetup::class
46 );
47 
48 $data = [['form_code' => 'customer_address_edit', 'attribute_id' => $model->getAttributeId()]];
49 $setupResource->getSetup()->getConnection()->insertMultiple(
50  $setupResource->getSetup()->getTable('customer_form_attribute'),
51  $data
52 );
53 
54 $data2 = [['form_code' => 'customer_address_edit', 'attribute_id' => $model2->getAttributeId()]];
55 $setupResource->getSetup()->getConnection()->insertMultiple(
56  $setupResource->getSetup()->getTable('customer_form_attribute'),
57  $data2
58 );