<table class="bash">
<tr class="li1"><td class="ln"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 . 创建一个PacktCustomerAttribute模块添加customer的属性 appcodePacktCustomerAttributeetcmodule.xml的内容: ?xml =? config xmlns:=xsi:= module = = sequence module = sequence module config 、在 appcodePacktCustomerAttribute下,创建文件 registration.PHP: ?PHP \Magento\Framework\Component\ComponentRegistrar::register \Magento\Framework\Component\ComponentRegistrar::MODULE, , __DIR__ ; 、创建数据安装脚本:appcodePacktCustomerAttributeSetupInstallData.PHP ?PHP namespace Packt\CustomerAttribute\Setup; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface private ; public __construct\Magento\Customer\Setup\CustomerSetupFactory -customerSetupFactory = ; public ModuleDataSetupInterface ,ModuleContextInterface var CustomerSetup = -customerSetupFactory-create= ; -startSetup; -addAttribute,, = , = , = , required' = , = , = , ; = -getEavConfig-getAttribute,; -setData,; -save; -endSetup; 、添加属性到后台,我们要创建一个ui_component XML文件appcodePacktCustomerAttributeviewbaseui_componentcustomer_form.xml ?xml = =? form xmlns:= xsi:= fieldset = field = argument = xsi:= item = xsi:= item = xsi:=textitem item =xsi:=inputitem item =xsi:=customeritem item argument field fieldset form . 最后执行命令 PHP binmagento setup:upgrade: