使用Magento\Customer SetFactory;使用Magento\Customer\Model\Customer;使用Magento\Eav\Model\Entity\ AttributeSet;使用Magento\Eav\Model\AttributeSet\ AttributeSetFactory;使用Magento\Framework\ InstallDataInterface;使用AttributeSet use Magento\Framework\Setup\ModuleDataSetupInterface;class InstallData InstallData InstallDataInterface{受保护的$customerSetupFactory;公共函数__construct(CustomerSetupFactory $customerSetupFactory,AttributeSetFactory $attributeSetFactory) { $this->customerSetupFactory = $customerSetupFactory;$this->属性设置工厂= $attributeSetFactory;}公共函数安装(ModuleDataSetupInterface $setup,ModuleContextInterface $context) { $customerSetup =$this->customerSetupFactory->create(‘Setuer=>$setup];$customerEntity =$customerEntity= $customerEntity->getDefaultAttributeSetId();$attributeSet->getDefaultGroupId($attributeSetId);= $attributeSet =$$attributeSet->$attributeSet->$attributeSet()$customerSetup->addAttribute(Customer::ENTITY,'intrestedin',‘=> 'varchar',’标签‘’=>‘自定义字段’,‘输入’=>‘文本’,‘必需’=>真‘,可见’=>真‘,'user_defined’=>真,'sort_order‘=> 1000,“位置”=> 1000,“系统”=> 0,);$customerSetup->getEavConfig()->getAttribute(Customer::ENTITY,'mobile_number') ->addData([ 'attribute_set_id‘=> $attributeSetId,'attribute_group_id’=> $attributeGroupId,'used_in_forms‘=> 'adminhtml_customer','customer_account_create',]);$attribute->save();}
发布于 2018-02-06 07:05:02
请尝试创建一个模块并添加customer属性。您可以从这里创建模块- https://mage2gen.com/。
安装模块后,可以运行安装程序升级和部署命令。
https://stackoverflow.com/questions/48617211
复制相似问题