首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Magento2.2的客户注册中添加自定义字段?

如何在Magento2.2的客户注册中添加自定义字段?
EN

Stack Overflow用户
提问于 2018-02-05 06:53:05
回答 1查看 1.6K关注 0票数 1
  1. 我想在Magento2.2的客户注册中添加自定义字段
  2. 我试过遵循代码,但它不起作用。
  3. 我试过InstallData.php

使用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();}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-06 07:05:02

请尝试创建一个模块并添加customer属性。您可以从这里创建模块- https://mage2gen.com/

安装模块后,可以运行安装程序升级和部署命令。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48617211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档