Skip to main content

Posts

Showing posts from May, 2024

How to Create Customer Custom Attribute in Magento 2

  Here we will learn, How to create Customer Custom Magento 2 attribute . Note: We also have a separate module ( Magento 2 Custom Registration Fields ) that allows the admin to create custom fields for customers. Henceforth, using this module you can extend your customer sign-up form. For more information, you can check it on our store. Let’s start the process. We can achieve this by using the following methods: 1st Method: Using InstallData file Create the file Webkul\CustomAttribute\Setup\InstallData.php <?php namespace Webkul \ CustomAttribute \ 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 \ ModuleDataSetu