Skip to content

How to add customer attribute programmatically in Magento 2

Today, we will guide you on how to add customer attribute in Magento 2 programmatically. so now I am going to explain step by step.

You can download the module from the below GitHub repository: 

How to add customer attribute programmatically in Magento 2

Step 1: Create setup file InstallData.php in the Setup directory

we used the file: app/code/Dev/CustomerAttribute/Setup/InstallData.php

Step 2: Show Customer Attribute in Register form

We will add our phtml files to ‘’ reference name using

Now, create additional.phtml file, we will write the code to show the additional textbox:

Now Run the upgrade command to install our module.
You need to run a command using SSh from the root of your Magento instance. If you want to more command list then refer our another post which Magento 2 useful commands lists.

After you can check your new group code attribute at admin panel and register form.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Share via
Copy link
Powered by Social Snap