Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    How to create Customer Custom Attribute in Magento 2.0

    Here we will learn, How to create Customer Custom attribute in Magento 2.0.x


    Create the file Webkul\CustomAttribute\Setup\InstallData.php

    InstallData conforms to InstallDataInterface , which requires the implementation of the install method that accepts two parameters of type ModuleDataSetupInterface and ModuleContextInterface .

    Using the addAttribute method on the instance of Magento\Customer\Setup\CustomerSetupFactory, we are instructing Magento to add a number of attributes.

    . . .

    Comments (4)

    Add Your Comment

  • Mohit Arora
    Thanks.. I was getting error in the constructor. Thanks for such simple and easy to understand post.
    • Webkul Support
      Hi Mohit,
      I hope you are facing this error:
      [MagentoFrameworkExceptionLocalizedException] The attribute code ‘custom_attribute’ is reserved by system. Please try another attribute code

      This is because the attribute code with this name is already taken by the system. try with other attribute code.
      Replace “custom_attribute” with “my_custom_attribute” in your code.

      Mahesh SinghSr. Software Engineer (Magento)

      Webkul Software Pvt. Ltd. Contact : India (+91)-9650486699 USA (+1)-9143531684

      A 67 Sector 63 ,
      Noida-201301 (U.P.)

      This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not disseminate, copy, distribute, or use this email or the information contained in it for any purpose other than to notify us. If you have received this message in error, please notify the sender immediately, and delete this email from your system.

  • Kirti Nariya
    How to show customer created attributes in front Billing and customer registration form magento 2
  • Jarnail
    How to add more than one attributes?
  • Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again