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 4: Show Customer Attribute in Register form

We will add our phtml files to ‘’ reference name using Dev/CustomerAttribute/view/frontend/layout/customer_account_create.xml Now, create additional.phtml file, we will write the code to show the additional textbox: Dev/CustomerAttribute/view/frontend/templates/additional.phtml 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.

One Comment

  1. Like!! I blog quite often and I genuinely thank you for your information. The article has truly peaked my interest.

Leave a Reply

Your email address will not be published.

Share via
Copy link
Powered by Social Snap