Magento 2.2. Customer Custom Attribute












1















I want add bonus to my customer, in the internet i read that i need use custom attribute.



etc/Module.xml



<module name="Kt_Addbonus" setup_version="1.2.2">
<sequence>
<module name="Customer"/>
</sequence>
</module>


Setup/InstallData.php



<?php

use MagentoCustomerSetupCustomerSetupFactory;
use MagentoCustomerModelCustomer;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;



class InstallData implements InstallDataInterface
{

/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;
/**
* @var AttributeSetFactory
*/
private $attributeSetFactory;


public function __construct( CustomerSetupFactory $customerSetupFactory,
AttributeSetFactory $attributeSetFactory)
{

$this->customerSetupFactory = $customerSetupFactory;
$this->attributeSetFactory = $attributeSetFactory;
}


/**
* Installs data for a module
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

$setup->startSetup();

$attributesInfo = [
'customer_bonus' => [
'label' => 'Customer Bonus',
'type' => 'int',
'input' => 'text',
'position' => 1000,
'visible' => true,
'required' => false,
'system' => 0,
'user_defined' => true,

]
];

$customerEntity =$customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultGroupId();

$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

foreach ($attributesInfo as $attributeCode => $attributeParams) {
$customerSetup->addAttribute(Customer::ENTITY, $attributeCode, $attributeParams);
}


$customerBonusAttribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'customer_bonus');
$customerBonusAttribute->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms'=>['adminhtml_customer']
]);

$customerBonusAttribute->save();
$setup->endSetup();

}
}


Custom attribute dont add to db or admin`s create customer page.
And PhpStorm says me that CustomerSetupFactory undefind, i already tried



setup:di:compile
setup:upgrade and cache:flush


did too.



Update 1



CustomerSetupFactory was generated. But custom attribute still not added.










share|improve this question





























    1















    I want add bonus to my customer, in the internet i read that i need use custom attribute.



    etc/Module.xml



    <module name="Kt_Addbonus" setup_version="1.2.2">
    <sequence>
    <module name="Customer"/>
    </sequence>
    </module>


    Setup/InstallData.php



    <?php

    use MagentoCustomerSetupCustomerSetupFactory;
    use MagentoCustomerModelCustomer;
    use MagentoFrameworkSetupInstallDataInterface;
    use MagentoFrameworkSetupModuleContextInterface;
    use MagentoFrameworkSetupModuleDataSetupInterface;
    use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;



    class InstallData implements InstallDataInterface
    {

    /**
    * @var CustomerSetupFactory
    */
    private $customerSetupFactory;
    /**
    * @var AttributeSetFactory
    */
    private $attributeSetFactory;


    public function __construct( CustomerSetupFactory $customerSetupFactory,
    AttributeSetFactory $attributeSetFactory)
    {

    $this->customerSetupFactory = $customerSetupFactory;
    $this->attributeSetFactory = $attributeSetFactory;
    }


    /**
    * Installs data for a module
    *
    * @param ModuleDataSetupInterface $setup
    * @param ModuleContextInterface $context
    * @return void
    */
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
    $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

    $setup->startSetup();

    $attributesInfo = [
    'customer_bonus' => [
    'label' => 'Customer Bonus',
    'type' => 'int',
    'input' => 'text',
    'position' => 1000,
    'visible' => true,
    'required' => false,
    'system' => 0,
    'user_defined' => true,

    ]
    ];

    $customerEntity =$customerSetup->getEavConfig()->getEntityType('customer');
    $attributeSetId = $customerEntity->getDefaultGroupId();

    $attributeSet = $this->attributeSetFactory->create();
    $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

    foreach ($attributesInfo as $attributeCode => $attributeParams) {
    $customerSetup->addAttribute(Customer::ENTITY, $attributeCode, $attributeParams);
    }


    $customerBonusAttribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'customer_bonus');
    $customerBonusAttribute->addData([
    'attribute_set_id' => $attributeSetId,
    'attribute_group_id' => $attributeGroupId,
    'used_in_forms'=>['adminhtml_customer']
    ]);

    $customerBonusAttribute->save();
    $setup->endSetup();

    }
    }


    Custom attribute dont add to db or admin`s create customer page.
    And PhpStorm says me that CustomerSetupFactory undefind, i already tried



    setup:di:compile
    setup:upgrade and cache:flush


    did too.



    Update 1



    CustomerSetupFactory was generated. But custom attribute still not added.










    share|improve this question



























      1












      1








      1








      I want add bonus to my customer, in the internet i read that i need use custom attribute.



      etc/Module.xml



      <module name="Kt_Addbonus" setup_version="1.2.2">
      <sequence>
      <module name="Customer"/>
      </sequence>
      </module>


      Setup/InstallData.php



      <?php

      use MagentoCustomerSetupCustomerSetupFactory;
      use MagentoCustomerModelCustomer;
      use MagentoFrameworkSetupInstallDataInterface;
      use MagentoFrameworkSetupModuleContextInterface;
      use MagentoFrameworkSetupModuleDataSetupInterface;
      use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;



      class InstallData implements InstallDataInterface
      {

      /**
      * @var CustomerSetupFactory
      */
      private $customerSetupFactory;
      /**
      * @var AttributeSetFactory
      */
      private $attributeSetFactory;


      public function __construct( CustomerSetupFactory $customerSetupFactory,
      AttributeSetFactory $attributeSetFactory)
      {

      $this->customerSetupFactory = $customerSetupFactory;
      $this->attributeSetFactory = $attributeSetFactory;
      }


      /**
      * Installs data for a module
      *
      * @param ModuleDataSetupInterface $setup
      * @param ModuleContextInterface $context
      * @return void
      */
      public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
      {
      $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

      $setup->startSetup();

      $attributesInfo = [
      'customer_bonus' => [
      'label' => 'Customer Bonus',
      'type' => 'int',
      'input' => 'text',
      'position' => 1000,
      'visible' => true,
      'required' => false,
      'system' => 0,
      'user_defined' => true,

      ]
      ];

      $customerEntity =$customerSetup->getEavConfig()->getEntityType('customer');
      $attributeSetId = $customerEntity->getDefaultGroupId();

      $attributeSet = $this->attributeSetFactory->create();
      $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

      foreach ($attributesInfo as $attributeCode => $attributeParams) {
      $customerSetup->addAttribute(Customer::ENTITY, $attributeCode, $attributeParams);
      }


      $customerBonusAttribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'customer_bonus');
      $customerBonusAttribute->addData([
      'attribute_set_id' => $attributeSetId,
      'attribute_group_id' => $attributeGroupId,
      'used_in_forms'=>['adminhtml_customer']
      ]);

      $customerBonusAttribute->save();
      $setup->endSetup();

      }
      }


      Custom attribute dont add to db or admin`s create customer page.
      And PhpStorm says me that CustomerSetupFactory undefind, i already tried



      setup:di:compile
      setup:upgrade and cache:flush


      did too.



      Update 1



      CustomerSetupFactory was generated. But custom attribute still not added.










      share|improve this question
















      I want add bonus to my customer, in the internet i read that i need use custom attribute.



      etc/Module.xml



      <module name="Kt_Addbonus" setup_version="1.2.2">
      <sequence>
      <module name="Customer"/>
      </sequence>
      </module>


      Setup/InstallData.php



      <?php

      use MagentoCustomerSetupCustomerSetupFactory;
      use MagentoCustomerModelCustomer;
      use MagentoFrameworkSetupInstallDataInterface;
      use MagentoFrameworkSetupModuleContextInterface;
      use MagentoFrameworkSetupModuleDataSetupInterface;
      use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;



      class InstallData implements InstallDataInterface
      {

      /**
      * @var CustomerSetupFactory
      */
      private $customerSetupFactory;
      /**
      * @var AttributeSetFactory
      */
      private $attributeSetFactory;


      public function __construct( CustomerSetupFactory $customerSetupFactory,
      AttributeSetFactory $attributeSetFactory)
      {

      $this->customerSetupFactory = $customerSetupFactory;
      $this->attributeSetFactory = $attributeSetFactory;
      }


      /**
      * Installs data for a module
      *
      * @param ModuleDataSetupInterface $setup
      * @param ModuleContextInterface $context
      * @return void
      */
      public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
      {
      $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

      $setup->startSetup();

      $attributesInfo = [
      'customer_bonus' => [
      'label' => 'Customer Bonus',
      'type' => 'int',
      'input' => 'text',
      'position' => 1000,
      'visible' => true,
      'required' => false,
      'system' => 0,
      'user_defined' => true,

      ]
      ];

      $customerEntity =$customerSetup->getEavConfig()->getEntityType('customer');
      $attributeSetId = $customerEntity->getDefaultGroupId();

      $attributeSet = $this->attributeSetFactory->create();
      $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

      foreach ($attributesInfo as $attributeCode => $attributeParams) {
      $customerSetup->addAttribute(Customer::ENTITY, $attributeCode, $attributeParams);
      }


      $customerBonusAttribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'customer_bonus');
      $customerBonusAttribute->addData([
      'attribute_set_id' => $attributeSetId,
      'attribute_group_id' => $attributeGroupId,
      'used_in_forms'=>['adminhtml_customer']
      ]);

      $customerBonusAttribute->save();
      $setup->endSetup();

      }
      }


      Custom attribute dont add to db or admin`s create customer page.
      And PhpStorm says me that CustomerSetupFactory undefind, i already tried



      setup:di:compile
      setup:upgrade and cache:flush


      did too.



      Update 1



      CustomerSetupFactory was generated. But custom attribute still not added.







      magento2 customer-attribute php-7






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 30 mins ago









      Teja Bhagavan Kollepara

      2,96341847




      2,96341847










      asked Mar 6 '18 at 7:00









      newakkoffnewakkoff

      1086




      1086






















          3 Answers
          3






          active

          oldest

          votes


















          1














          Please confirm that have you created registration.php on your module root folder like :



          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE, 'Kt_Addbonus', __DIR__
          );


          Also replace following code into your InstallData.php



          <?php

          namespace KtAddbonusSetup;

          use MagentoFrameworkSetupInstallDataInterface;
          use MagentoFrameworkSetupModuleContextInterface;
          use MagentoFrameworkSetupModuleDataSetupInterface;

          class InstallData implements InstallDataInterface
          {

          private $customerSetupFactory;
          private $attributeSetFactory;

          public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory, MagentoEavModelEntityAttributeSetFactory $attributeSetFactory)
          {
          $this->customerSetupFactory = $customerSetupFactory;
          $this->attributeSetFactory = $attributeSetFactory;
          }

          public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
          {
          $installer = $setup;
          $installer->startSetup();

          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
          $customerSetup->removeAttribute(MagentoCustomerModelCustomer::ENTITY, "customer_bonus");

          $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
          $attributeSetId = $customerEntity->getDefaultAttributeSetId();
          $attributeSet = $this->attributeSetFactory->create();
          $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);


          $customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'customer_bonus', [
          'type' => 'varchar',
          'label' => 'Customer Bonus',
          'input' => 'text',
          'required' => false,
          'visible' => true,
          'user_defined' => true,
          'system' => false,
          ]);

          $attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'customer_bonus')
          ->addData([
          'attribute_set_id' => $attributeSetId,
          'attribute_group_id' => $attributeGroupId,
          'used_in_forms'=>['adminhtml_customer']
          ]);

          $attribute->save();

          $installer->endSetup();
          }

          }


          After above you have to run your extension again you need to remove your extension entry from setup_module table also then run below command



          php bin/magento setup:upgrade


          Thanks






          share|improve this answer
























          • Means attribute is not created or you got any error ?

            – Hardik Patel
            Mar 6 '18 at 8:01











          • attribute is not created, i have no any error

            – newakkoff
            Mar 6 '18 at 8:01











          • oh no im sorry, its work, your answer added customer_bonus attribute to eav_attribute and customer_eav_attribute tables, thank you very much.

            – newakkoff
            Mar 6 '18 at 8:16



















          1














          I think your missing namespace in your setup script,



          <?php
          namespace KtAddbonusSetup;

          use MagentoCustomerSetupCustomerSetupFactory;
          use MagentoCustomerModelCustomer;
          use MagentoEavModelEntityAttributeSet as AttributeSet;
          use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
          use MagentoFrameworkSetupInstallDataInterface;
          use MagentoFrameworkSetupModuleContextInterface;
          use MagentoFrameworkSetupModuleDataSetupInterface;

          /**
          * @codeCoverageIgnore
          */
          class InstallData implements InstallDataInterface
          {

          /**
          * @var CustomerSetupFactory
          */
          protected $customerSetupFactory;

          /**
          * @var AttributeSetFactory
          */
          private $attributeSetFactory;

          /**
          * @param CustomerSetupFactory $customerSetupFactory
          * @param AttributeSetFactory $attributeSetFactory
          */
          public function __construct(
          CustomerSetupFactory $customerSetupFactory,
          AttributeSetFactory $attributeSetFactory
          ) {
          $this->customerSetupFactory = $customerSetupFactory;
          $this->attributeSetFactory = $attributeSetFactory;
          }


          public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
          {

          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

          $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
          $attributeSetId = $customerEntity->getDefaultAttributeSetId();

          /** @var $attributeSet AttributeSet */
          $attributeSet = $this->attributeSetFactory->create();
          $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

          $customerSetup->addAttribute(Customer::ENTITY, 'custom_attribute', [
          'type' => 'varchar',
          'label' => 'Customer Bonus',
          'input' => 'text',
          'required' => false,
          'visible' => true,
          'user_defined' => true,
          'position' =>999,
          'system' => 0,
          ]);

          $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'custom_attribute')
          ->addData([
          'attribute_set_id' => $attributeSetId,
          'attribute_group_id' => $attributeGroupId,
          'used_in_forms' => ['adminhtml_customer'],//you can use other forms also ['adminhtml_customer_address', 'customer_address_edit', 'customer_register_address']
          ]);

          $attribute->save();
          }
          }





          share|improve this answer


























          • thank you for your answer, unfortunately it did not help.

            – newakkoff
            Mar 6 '18 at 7:23











          • what error coming same?

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:29











          • @newakkoff check this mageplaza.com/magento-2-module-development/…

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:38











          • thank you, but i already tried all guides in internet)

            – newakkoff
            Mar 6 '18 at 7:39











          • @newakkoff mage2gen.com try this extension creator. Create the extension and update it. This extension will give clear definition for you..

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:43





















          0














          You can not easily use custom customer attributes in Magento 2 community edition.
          It's a paid feature in Enterprise Edition.



          You can add it programmatically but in my opinion they done a lot to make it as difficult as possible.



          See this thread for reference:
          https://github.com/magento/magento2/issues/6575






          share|improve this answer
























          • thanks if it's a paid function, then it's better to add a column to customer_entity, right? and extend CustomerInterface, Can I do that?

            – newakkoff
            Mar 6 '18 at 7:37






          • 1





            However you do it, you have to extend and overwrite a lot of stuff backend and frontend wise to make it work. See the linked thread or maybe look at an extension that does it. If you are not deep in the topic and do not want to dive deep. I'd rather suggest using an extension.

            – steros
            Mar 6 '18 at 7:48











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f216104%2fmagento-2-2-customer-custom-attribute%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Please confirm that have you created registration.php on your module root folder like :



          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE, 'Kt_Addbonus', __DIR__
          );


          Also replace following code into your InstallData.php



          <?php

          namespace KtAddbonusSetup;

          use MagentoFrameworkSetupInstallDataInterface;
          use MagentoFrameworkSetupModuleContextInterface;
          use MagentoFrameworkSetupModuleDataSetupInterface;

          class InstallData implements InstallDataInterface
          {

          private $customerSetupFactory;
          private $attributeSetFactory;

          public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory, MagentoEavModelEntityAttributeSetFactory $attributeSetFactory)
          {
          $this->customerSetupFactory = $customerSetupFactory;
          $this->attributeSetFactory = $attributeSetFactory;
          }

          public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
          {
          $installer = $setup;
          $installer->startSetup();

          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
          $customerSetup->removeAttribute(MagentoCustomerModelCustomer::ENTITY, "customer_bonus");

          $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
          $attributeSetId = $customerEntity->getDefaultAttributeSetId();
          $attributeSet = $this->attributeSetFactory->create();
          $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);


          $customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'customer_bonus', [
          'type' => 'varchar',
          'label' => 'Customer Bonus',
          'input' => 'text',
          'required' => false,
          'visible' => true,
          'user_defined' => true,
          'system' => false,
          ]);

          $attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'customer_bonus')
          ->addData([
          'attribute_set_id' => $attributeSetId,
          'attribute_group_id' => $attributeGroupId,
          'used_in_forms'=>['adminhtml_customer']
          ]);

          $attribute->save();

          $installer->endSetup();
          }

          }


          After above you have to run your extension again you need to remove your extension entry from setup_module table also then run below command



          php bin/magento setup:upgrade


          Thanks






          share|improve this answer
























          • Means attribute is not created or you got any error ?

            – Hardik Patel
            Mar 6 '18 at 8:01











          • attribute is not created, i have no any error

            – newakkoff
            Mar 6 '18 at 8:01











          • oh no im sorry, its work, your answer added customer_bonus attribute to eav_attribute and customer_eav_attribute tables, thank you very much.

            – newakkoff
            Mar 6 '18 at 8:16
















          1














          Please confirm that have you created registration.php on your module root folder like :



          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE, 'Kt_Addbonus', __DIR__
          );


          Also replace following code into your InstallData.php



          <?php

          namespace KtAddbonusSetup;

          use MagentoFrameworkSetupInstallDataInterface;
          use MagentoFrameworkSetupModuleContextInterface;
          use MagentoFrameworkSetupModuleDataSetupInterface;

          class InstallData implements InstallDataInterface
          {

          private $customerSetupFactory;
          private $attributeSetFactory;

          public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory, MagentoEavModelEntityAttributeSetFactory $attributeSetFactory)
          {
          $this->customerSetupFactory = $customerSetupFactory;
          $this->attributeSetFactory = $attributeSetFactory;
          }

          public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
          {
          $installer = $setup;
          $installer->startSetup();

          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
          $customerSetup->removeAttribute(MagentoCustomerModelCustomer::ENTITY, "customer_bonus");

          $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
          $attributeSetId = $customerEntity->getDefaultAttributeSetId();
          $attributeSet = $this->attributeSetFactory->create();
          $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);


          $customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'customer_bonus', [
          'type' => 'varchar',
          'label' => 'Customer Bonus',
          'input' => 'text',
          'required' => false,
          'visible' => true,
          'user_defined' => true,
          'system' => false,
          ]);

          $attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'customer_bonus')
          ->addData([
          'attribute_set_id' => $attributeSetId,
          'attribute_group_id' => $attributeGroupId,
          'used_in_forms'=>['adminhtml_customer']
          ]);

          $attribute->save();

          $installer->endSetup();
          }

          }


          After above you have to run your extension again you need to remove your extension entry from setup_module table also then run below command



          php bin/magento setup:upgrade


          Thanks






          share|improve this answer
























          • Means attribute is not created or you got any error ?

            – Hardik Patel
            Mar 6 '18 at 8:01











          • attribute is not created, i have no any error

            – newakkoff
            Mar 6 '18 at 8:01











          • oh no im sorry, its work, your answer added customer_bonus attribute to eav_attribute and customer_eav_attribute tables, thank you very much.

            – newakkoff
            Mar 6 '18 at 8:16














          1












          1








          1







          Please confirm that have you created registration.php on your module root folder like :



          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE, 'Kt_Addbonus', __DIR__
          );


          Also replace following code into your InstallData.php



          <?php

          namespace KtAddbonusSetup;

          use MagentoFrameworkSetupInstallDataInterface;
          use MagentoFrameworkSetupModuleContextInterface;
          use MagentoFrameworkSetupModuleDataSetupInterface;

          class InstallData implements InstallDataInterface
          {

          private $customerSetupFactory;
          private $attributeSetFactory;

          public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory, MagentoEavModelEntityAttributeSetFactory $attributeSetFactory)
          {
          $this->customerSetupFactory = $customerSetupFactory;
          $this->attributeSetFactory = $attributeSetFactory;
          }

          public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
          {
          $installer = $setup;
          $installer->startSetup();

          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
          $customerSetup->removeAttribute(MagentoCustomerModelCustomer::ENTITY, "customer_bonus");

          $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
          $attributeSetId = $customerEntity->getDefaultAttributeSetId();
          $attributeSet = $this->attributeSetFactory->create();
          $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);


          $customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'customer_bonus', [
          'type' => 'varchar',
          'label' => 'Customer Bonus',
          'input' => 'text',
          'required' => false,
          'visible' => true,
          'user_defined' => true,
          'system' => false,
          ]);

          $attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'customer_bonus')
          ->addData([
          'attribute_set_id' => $attributeSetId,
          'attribute_group_id' => $attributeGroupId,
          'used_in_forms'=>['adminhtml_customer']
          ]);

          $attribute->save();

          $installer->endSetup();
          }

          }


          After above you have to run your extension again you need to remove your extension entry from setup_module table also then run below command



          php bin/magento setup:upgrade


          Thanks






          share|improve this answer













          Please confirm that have you created registration.php on your module root folder like :



          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE, 'Kt_Addbonus', __DIR__
          );


          Also replace following code into your InstallData.php



          <?php

          namespace KtAddbonusSetup;

          use MagentoFrameworkSetupInstallDataInterface;
          use MagentoFrameworkSetupModuleContextInterface;
          use MagentoFrameworkSetupModuleDataSetupInterface;

          class InstallData implements InstallDataInterface
          {

          private $customerSetupFactory;
          private $attributeSetFactory;

          public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory, MagentoEavModelEntityAttributeSetFactory $attributeSetFactory)
          {
          $this->customerSetupFactory = $customerSetupFactory;
          $this->attributeSetFactory = $attributeSetFactory;
          }

          public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
          {
          $installer = $setup;
          $installer->startSetup();

          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
          $customerSetup->removeAttribute(MagentoCustomerModelCustomer::ENTITY, "customer_bonus");

          $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
          $attributeSetId = $customerEntity->getDefaultAttributeSetId();
          $attributeSet = $this->attributeSetFactory->create();
          $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);


          $customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'customer_bonus', [
          'type' => 'varchar',
          'label' => 'Customer Bonus',
          'input' => 'text',
          'required' => false,
          'visible' => true,
          'user_defined' => true,
          'system' => false,
          ]);

          $attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'customer_bonus')
          ->addData([
          'attribute_set_id' => $attributeSetId,
          'attribute_group_id' => $attributeGroupId,
          'used_in_forms'=>['adminhtml_customer']
          ]);

          $attribute->save();

          $installer->endSetup();
          }

          }


          After above you have to run your extension again you need to remove your extension entry from setup_module table also then run below command



          php bin/magento setup:upgrade


          Thanks







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 6 '18 at 7:26









          Hardik PatelHardik Patel

          508313




          508313













          • Means attribute is not created or you got any error ?

            – Hardik Patel
            Mar 6 '18 at 8:01











          • attribute is not created, i have no any error

            – newakkoff
            Mar 6 '18 at 8:01











          • oh no im sorry, its work, your answer added customer_bonus attribute to eav_attribute and customer_eav_attribute tables, thank you very much.

            – newakkoff
            Mar 6 '18 at 8:16



















          • Means attribute is not created or you got any error ?

            – Hardik Patel
            Mar 6 '18 at 8:01











          • attribute is not created, i have no any error

            – newakkoff
            Mar 6 '18 at 8:01











          • oh no im sorry, its work, your answer added customer_bonus attribute to eav_attribute and customer_eav_attribute tables, thank you very much.

            – newakkoff
            Mar 6 '18 at 8:16

















          Means attribute is not created or you got any error ?

          – Hardik Patel
          Mar 6 '18 at 8:01





          Means attribute is not created or you got any error ?

          – Hardik Patel
          Mar 6 '18 at 8:01













          attribute is not created, i have no any error

          – newakkoff
          Mar 6 '18 at 8:01





          attribute is not created, i have no any error

          – newakkoff
          Mar 6 '18 at 8:01













          oh no im sorry, its work, your answer added customer_bonus attribute to eav_attribute and customer_eav_attribute tables, thank you very much.

          – newakkoff
          Mar 6 '18 at 8:16





          oh no im sorry, its work, your answer added customer_bonus attribute to eav_attribute and customer_eav_attribute tables, thank you very much.

          – newakkoff
          Mar 6 '18 at 8:16













          1














          I think your missing namespace in your setup script,



          <?php
          namespace KtAddbonusSetup;

          use MagentoCustomerSetupCustomerSetupFactory;
          use MagentoCustomerModelCustomer;
          use MagentoEavModelEntityAttributeSet as AttributeSet;
          use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
          use MagentoFrameworkSetupInstallDataInterface;
          use MagentoFrameworkSetupModuleContextInterface;
          use MagentoFrameworkSetupModuleDataSetupInterface;

          /**
          * @codeCoverageIgnore
          */
          class InstallData implements InstallDataInterface
          {

          /**
          * @var CustomerSetupFactory
          */
          protected $customerSetupFactory;

          /**
          * @var AttributeSetFactory
          */
          private $attributeSetFactory;

          /**
          * @param CustomerSetupFactory $customerSetupFactory
          * @param AttributeSetFactory $attributeSetFactory
          */
          public function __construct(
          CustomerSetupFactory $customerSetupFactory,
          AttributeSetFactory $attributeSetFactory
          ) {
          $this->customerSetupFactory = $customerSetupFactory;
          $this->attributeSetFactory = $attributeSetFactory;
          }


          public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
          {

          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

          $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
          $attributeSetId = $customerEntity->getDefaultAttributeSetId();

          /** @var $attributeSet AttributeSet */
          $attributeSet = $this->attributeSetFactory->create();
          $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

          $customerSetup->addAttribute(Customer::ENTITY, 'custom_attribute', [
          'type' => 'varchar',
          'label' => 'Customer Bonus',
          'input' => 'text',
          'required' => false,
          'visible' => true,
          'user_defined' => true,
          'position' =>999,
          'system' => 0,
          ]);

          $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'custom_attribute')
          ->addData([
          'attribute_set_id' => $attributeSetId,
          'attribute_group_id' => $attributeGroupId,
          'used_in_forms' => ['adminhtml_customer'],//you can use other forms also ['adminhtml_customer_address', 'customer_address_edit', 'customer_register_address']
          ]);

          $attribute->save();
          }
          }





          share|improve this answer


























          • thank you for your answer, unfortunately it did not help.

            – newakkoff
            Mar 6 '18 at 7:23











          • what error coming same?

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:29











          • @newakkoff check this mageplaza.com/magento-2-module-development/…

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:38











          • thank you, but i already tried all guides in internet)

            – newakkoff
            Mar 6 '18 at 7:39











          • @newakkoff mage2gen.com try this extension creator. Create the extension and update it. This extension will give clear definition for you..

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:43


















          1














          I think your missing namespace in your setup script,



          <?php
          namespace KtAddbonusSetup;

          use MagentoCustomerSetupCustomerSetupFactory;
          use MagentoCustomerModelCustomer;
          use MagentoEavModelEntityAttributeSet as AttributeSet;
          use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
          use MagentoFrameworkSetupInstallDataInterface;
          use MagentoFrameworkSetupModuleContextInterface;
          use MagentoFrameworkSetupModuleDataSetupInterface;

          /**
          * @codeCoverageIgnore
          */
          class InstallData implements InstallDataInterface
          {

          /**
          * @var CustomerSetupFactory
          */
          protected $customerSetupFactory;

          /**
          * @var AttributeSetFactory
          */
          private $attributeSetFactory;

          /**
          * @param CustomerSetupFactory $customerSetupFactory
          * @param AttributeSetFactory $attributeSetFactory
          */
          public function __construct(
          CustomerSetupFactory $customerSetupFactory,
          AttributeSetFactory $attributeSetFactory
          ) {
          $this->customerSetupFactory = $customerSetupFactory;
          $this->attributeSetFactory = $attributeSetFactory;
          }


          public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
          {

          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

          $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
          $attributeSetId = $customerEntity->getDefaultAttributeSetId();

          /** @var $attributeSet AttributeSet */
          $attributeSet = $this->attributeSetFactory->create();
          $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

          $customerSetup->addAttribute(Customer::ENTITY, 'custom_attribute', [
          'type' => 'varchar',
          'label' => 'Customer Bonus',
          'input' => 'text',
          'required' => false,
          'visible' => true,
          'user_defined' => true,
          'position' =>999,
          'system' => 0,
          ]);

          $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'custom_attribute')
          ->addData([
          'attribute_set_id' => $attributeSetId,
          'attribute_group_id' => $attributeGroupId,
          'used_in_forms' => ['adminhtml_customer'],//you can use other forms also ['adminhtml_customer_address', 'customer_address_edit', 'customer_register_address']
          ]);

          $attribute->save();
          }
          }





          share|improve this answer


























          • thank you for your answer, unfortunately it did not help.

            – newakkoff
            Mar 6 '18 at 7:23











          • what error coming same?

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:29











          • @newakkoff check this mageplaza.com/magento-2-module-development/…

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:38











          • thank you, but i already tried all guides in internet)

            – newakkoff
            Mar 6 '18 at 7:39











          • @newakkoff mage2gen.com try this extension creator. Create the extension and update it. This extension will give clear definition for you..

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:43
















          1












          1








          1







          I think your missing namespace in your setup script,



          <?php
          namespace KtAddbonusSetup;

          use MagentoCustomerSetupCustomerSetupFactory;
          use MagentoCustomerModelCustomer;
          use MagentoEavModelEntityAttributeSet as AttributeSet;
          use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
          use MagentoFrameworkSetupInstallDataInterface;
          use MagentoFrameworkSetupModuleContextInterface;
          use MagentoFrameworkSetupModuleDataSetupInterface;

          /**
          * @codeCoverageIgnore
          */
          class InstallData implements InstallDataInterface
          {

          /**
          * @var CustomerSetupFactory
          */
          protected $customerSetupFactory;

          /**
          * @var AttributeSetFactory
          */
          private $attributeSetFactory;

          /**
          * @param CustomerSetupFactory $customerSetupFactory
          * @param AttributeSetFactory $attributeSetFactory
          */
          public function __construct(
          CustomerSetupFactory $customerSetupFactory,
          AttributeSetFactory $attributeSetFactory
          ) {
          $this->customerSetupFactory = $customerSetupFactory;
          $this->attributeSetFactory = $attributeSetFactory;
          }


          public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
          {

          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

          $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
          $attributeSetId = $customerEntity->getDefaultAttributeSetId();

          /** @var $attributeSet AttributeSet */
          $attributeSet = $this->attributeSetFactory->create();
          $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

          $customerSetup->addAttribute(Customer::ENTITY, 'custom_attribute', [
          'type' => 'varchar',
          'label' => 'Customer Bonus',
          'input' => 'text',
          'required' => false,
          'visible' => true,
          'user_defined' => true,
          'position' =>999,
          'system' => 0,
          ]);

          $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'custom_attribute')
          ->addData([
          'attribute_set_id' => $attributeSetId,
          'attribute_group_id' => $attributeGroupId,
          'used_in_forms' => ['adminhtml_customer'],//you can use other forms also ['adminhtml_customer_address', 'customer_address_edit', 'customer_register_address']
          ]);

          $attribute->save();
          }
          }





          share|improve this answer















          I think your missing namespace in your setup script,



          <?php
          namespace KtAddbonusSetup;

          use MagentoCustomerSetupCustomerSetupFactory;
          use MagentoCustomerModelCustomer;
          use MagentoEavModelEntityAttributeSet as AttributeSet;
          use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
          use MagentoFrameworkSetupInstallDataInterface;
          use MagentoFrameworkSetupModuleContextInterface;
          use MagentoFrameworkSetupModuleDataSetupInterface;

          /**
          * @codeCoverageIgnore
          */
          class InstallData implements InstallDataInterface
          {

          /**
          * @var CustomerSetupFactory
          */
          protected $customerSetupFactory;

          /**
          * @var AttributeSetFactory
          */
          private $attributeSetFactory;

          /**
          * @param CustomerSetupFactory $customerSetupFactory
          * @param AttributeSetFactory $attributeSetFactory
          */
          public function __construct(
          CustomerSetupFactory $customerSetupFactory,
          AttributeSetFactory $attributeSetFactory
          ) {
          $this->customerSetupFactory = $customerSetupFactory;
          $this->attributeSetFactory = $attributeSetFactory;
          }


          public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
          {

          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

          $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
          $attributeSetId = $customerEntity->getDefaultAttributeSetId();

          /** @var $attributeSet AttributeSet */
          $attributeSet = $this->attributeSetFactory->create();
          $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

          $customerSetup->addAttribute(Customer::ENTITY, 'custom_attribute', [
          'type' => 'varchar',
          'label' => 'Customer Bonus',
          'input' => 'text',
          'required' => false,
          'visible' => true,
          'user_defined' => true,
          'position' =>999,
          'system' => 0,
          ]);

          $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'custom_attribute')
          ->addData([
          'attribute_set_id' => $attributeSetId,
          'attribute_group_id' => $attributeGroupId,
          'used_in_forms' => ['adminhtml_customer'],//you can use other forms also ['adminhtml_customer_address', 'customer_address_edit', 'customer_register_address']
          ]);

          $attribute->save();
          }
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 6 '18 at 7:52

























          answered Mar 6 '18 at 7:04









          Jeeva ChezhiyanJeeva Chezhiyan

          732524




          732524













          • thank you for your answer, unfortunately it did not help.

            – newakkoff
            Mar 6 '18 at 7:23











          • what error coming same?

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:29











          • @newakkoff check this mageplaza.com/magento-2-module-development/…

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:38











          • thank you, but i already tried all guides in internet)

            – newakkoff
            Mar 6 '18 at 7:39











          • @newakkoff mage2gen.com try this extension creator. Create the extension and update it. This extension will give clear definition for you..

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:43





















          • thank you for your answer, unfortunately it did not help.

            – newakkoff
            Mar 6 '18 at 7:23











          • what error coming same?

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:29











          • @newakkoff check this mageplaza.com/magento-2-module-development/…

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:38











          • thank you, but i already tried all guides in internet)

            – newakkoff
            Mar 6 '18 at 7:39











          • @newakkoff mage2gen.com try this extension creator. Create the extension and update it. This extension will give clear definition for you..

            – Jeeva Chezhiyan
            Mar 6 '18 at 7:43



















          thank you for your answer, unfortunately it did not help.

          – newakkoff
          Mar 6 '18 at 7:23





          thank you for your answer, unfortunately it did not help.

          – newakkoff
          Mar 6 '18 at 7:23













          what error coming same?

          – Jeeva Chezhiyan
          Mar 6 '18 at 7:29





          what error coming same?

          – Jeeva Chezhiyan
          Mar 6 '18 at 7:29













          @newakkoff check this mageplaza.com/magento-2-module-development/…

          – Jeeva Chezhiyan
          Mar 6 '18 at 7:38





          @newakkoff check this mageplaza.com/magento-2-module-development/…

          – Jeeva Chezhiyan
          Mar 6 '18 at 7:38













          thank you, but i already tried all guides in internet)

          – newakkoff
          Mar 6 '18 at 7:39





          thank you, but i already tried all guides in internet)

          – newakkoff
          Mar 6 '18 at 7:39













          @newakkoff mage2gen.com try this extension creator. Create the extension and update it. This extension will give clear definition for you..

          – Jeeva Chezhiyan
          Mar 6 '18 at 7:43







          @newakkoff mage2gen.com try this extension creator. Create the extension and update it. This extension will give clear definition for you..

          – Jeeva Chezhiyan
          Mar 6 '18 at 7:43













          0














          You can not easily use custom customer attributes in Magento 2 community edition.
          It's a paid feature in Enterprise Edition.



          You can add it programmatically but in my opinion they done a lot to make it as difficult as possible.



          See this thread for reference:
          https://github.com/magento/magento2/issues/6575






          share|improve this answer
























          • thanks if it's a paid function, then it's better to add a column to customer_entity, right? and extend CustomerInterface, Can I do that?

            – newakkoff
            Mar 6 '18 at 7:37






          • 1





            However you do it, you have to extend and overwrite a lot of stuff backend and frontend wise to make it work. See the linked thread or maybe look at an extension that does it. If you are not deep in the topic and do not want to dive deep. I'd rather suggest using an extension.

            – steros
            Mar 6 '18 at 7:48
















          0














          You can not easily use custom customer attributes in Magento 2 community edition.
          It's a paid feature in Enterprise Edition.



          You can add it programmatically but in my opinion they done a lot to make it as difficult as possible.



          See this thread for reference:
          https://github.com/magento/magento2/issues/6575






          share|improve this answer
























          • thanks if it's a paid function, then it's better to add a column to customer_entity, right? and extend CustomerInterface, Can I do that?

            – newakkoff
            Mar 6 '18 at 7:37






          • 1





            However you do it, you have to extend and overwrite a lot of stuff backend and frontend wise to make it work. See the linked thread or maybe look at an extension that does it. If you are not deep in the topic and do not want to dive deep. I'd rather suggest using an extension.

            – steros
            Mar 6 '18 at 7:48














          0












          0








          0







          You can not easily use custom customer attributes in Magento 2 community edition.
          It's a paid feature in Enterprise Edition.



          You can add it programmatically but in my opinion they done a lot to make it as difficult as possible.



          See this thread for reference:
          https://github.com/magento/magento2/issues/6575






          share|improve this answer













          You can not easily use custom customer attributes in Magento 2 community edition.
          It's a paid feature in Enterprise Edition.



          You can add it programmatically but in my opinion they done a lot to make it as difficult as possible.



          See this thread for reference:
          https://github.com/magento/magento2/issues/6575







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 6 '18 at 7:27









          sterossteros

          822629




          822629













          • thanks if it's a paid function, then it's better to add a column to customer_entity, right? and extend CustomerInterface, Can I do that?

            – newakkoff
            Mar 6 '18 at 7:37






          • 1





            However you do it, you have to extend and overwrite a lot of stuff backend and frontend wise to make it work. See the linked thread or maybe look at an extension that does it. If you are not deep in the topic and do not want to dive deep. I'd rather suggest using an extension.

            – steros
            Mar 6 '18 at 7:48



















          • thanks if it's a paid function, then it's better to add a column to customer_entity, right? and extend CustomerInterface, Can I do that?

            – newakkoff
            Mar 6 '18 at 7:37






          • 1





            However you do it, you have to extend and overwrite a lot of stuff backend and frontend wise to make it work. See the linked thread or maybe look at an extension that does it. If you are not deep in the topic and do not want to dive deep. I'd rather suggest using an extension.

            – steros
            Mar 6 '18 at 7:48

















          thanks if it's a paid function, then it's better to add a column to customer_entity, right? and extend CustomerInterface, Can I do that?

          – newakkoff
          Mar 6 '18 at 7:37





          thanks if it's a paid function, then it's better to add a column to customer_entity, right? and extend CustomerInterface, Can I do that?

          – newakkoff
          Mar 6 '18 at 7:37




          1




          1





          However you do it, you have to extend and overwrite a lot of stuff backend and frontend wise to make it work. See the linked thread or maybe look at an extension that does it. If you are not deep in the topic and do not want to dive deep. I'd rather suggest using an extension.

          – steros
          Mar 6 '18 at 7:48





          However you do it, you have to extend and overwrite a lot of stuff backend and frontend wise to make it work. See the linked thread or maybe look at an extension that does it. If you are not deep in the topic and do not want to dive deep. I'd rather suggest using an extension.

          – steros
          Mar 6 '18 at 7:48


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f216104%2fmagento-2-2-customer-custom-attribute%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          What other Star Trek series did the main TNG cast show up in?

          Berlina muro

          Berlina aerponto