Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
attribute_user_defined_custom_attribute.php
Go to the documentation of this file.
1 <?php
8 
10 $attribute1 = $objectManager->create(\Magento\Customer\Model\Attribute::class);
11 $attribute1->setName(
12  'custom_attribute1'
13 )->setEntityTypeId(
14  1
15 )->setIsUserDefined(
16  1
17 )->setAttributeSetId(
18  1
19 )->setAttributeGroupId(
20  1
21 )->setFrontendInput(
22  'text'
23 )->setFrontendLabel(
24  'custom_attribute_frontend_label'
25 )->setBackendType(
26  'varchar'
27 )->setSortOrder(
28  1221
29 )->save();
30 
32 $attribute2 = $objectManager->create(\Magento\Customer\Model\Attribute::class);
33 $attribute2->setName(
34  'custom_attribute2'
35 )->setEntityTypeId(
36  1
37 )->setIsUserDefined(
38  1
39 )->setAttributeSetId(
40  1
41 )->setAttributeGroupId(
42  1
43 )->setFrontendInput(
44  'text'
45 )->setFrontendLabel(
46  'custom_attributes_frontend_label'
47 )->setSortOrder(
48  1222
49 )->save();
50 
52 $attribute3 = $objectManager->create(\Magento\Customer\Model\Attribute::class);
53 $attribute3->setName(
54  'customer_image'
55 )->setEntityTypeId(
56  1
57 )->setIsUserDefined(
58  1
59 )->setAttributeSetId(
60  1
61 )->setAttributeGroupId(
62  1
63 )->setFrontendInput(
64  'image'
65 )->setFrontendLabel(
66  'customer_image'
67 )->setBackendType(
68  'varchar'
69 )->setSortOrder(
70  1223
71 )->save();