Skip to main content

Posts

Showing posts with the label add customer attributes programetically #magento2

How to add custom attribute to customer programmatically?

How to Add Custom Attribute to Customer Programmatically? This post will guide you how to create customer custom attribute in Magento 2.0.x programatically. Firstly, you need create file InstallData.php in your setup folder: Create file: app/code/AGM/Exercise/Setup/InstallData.php Insert code as below and change your attribute name. <?php namespace AGM\Exercise\Setup; use Magento\Customer\Setup\CustomerSetupFactory; use Magento\Customer\Model\Customer; use Magento\Eav\Model\Entity\Attribute\Set as AttributeSet; use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface { /** * @var customerSetupFactory */ protected $customerSetupFactory ; /** * @var attributeSetFactory ...