I want to add a company field to the customer registration form, but i can not find the backend option for it. Is there a way i can do it programmatically?

enter image description here

2 Answers 2


Try this script.

namespace Mynamespace\Modulename\Setup;

use Magento\Framework\Module\Setup\Migration;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

class InstallData implements InstallDataInterface
     * Customer setup factory
     * @var \Magento\Customer\Setup\CustomerSetupFactory
    private $customerSetupFactory;
     * Init
     * @param \Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory
    public function __construct(\Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory)
        $this->customerSetupFactory = $customerSetupFactory;
     * Installs DB schema for a module
     * @param ModuleDataSetupInterface $setup
     * @param ModuleContextInterface $context
     * @return void
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)

        $installer = $setup;

        $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
        $entityTypeId = $customerSetup->getEntityTypeId(\Magento\Customer\Model\Customer::ENTITY);
        $customerSetup->removeAttribute(\Magento\Customer\Model\Customer::ENTITY, "company");

        $customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, "company",  array(
            "type"     => "varchar",
            "backend"  => "",
            "label"    => "company",
            "input"    => "text",
            "source"   => "",
            "visible"  => true,
            "required" => true,
            "default" => "",
            "frontend" => "",
            "unique"     => false,
            "note"       => ""


        $company   = $customerSetup->getAttribute(\Magento\Customer\Model\Customer::ENTITY, "company");

        $company = $customerSetup->getEavConfig()->getAttribute(\Magento\Customer\Model\Customer::ENTITY, 'company');
        $company->setData("used_in_forms", $used_in_forms)
            ->setData("is_used_for_customer_segment", true)
            ->setData("is_system", 0)
            ->setData("is_user_defined", 1)
            ->setData("is_visible", 1)
            ->setData("sort_order", 100);


  • 1
    Not working. And you're creating a new attribute, but i need to use the existing one...
    – Radosav
    Aug 31, 2016 at 10:44
  • Is there a working solution now? Dec 9, 2016 at 8:08
  • @Radosav there is no out of the box solution for it, Company field is only added to the customer_address entity type not customer, so you have to create custom attribute for it to work on customer entity type. Aug 6, 2020 at 6:03

This should be an easy and taken as a serious inquiry. Additional customer registration data is key for sorting and marketing to different customer groups.

  • This does not provide an answer to the question. I would request to please explain a bit more so that the answer can benefit someone. Feb 25, 2019 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.