Add a custom attribute in grid customer magento 2





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}






up vote
2
down vote

favorite












I have created an attribute type: select but i can't display it in the grid customer.
the code of my customer_listing.xml



<column name="customer_status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">select</item>
<item name="editor" xsi:type="string">select</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
<item name="dataType" xsi:type="string">select</item>
<item name="label" xsi:type="string" translate="true">Customer Status</item>
<item name="sortOrder" xsi:type="number">190</item>
</item>
</argument>
</column>


the code of the UpgradeData.php



$attributeCode7 = "customer_status";
$customerSetup->addAttribute(Customer::ENTITY, $attributeCode7, [
'type' => 'varchar',
'label' => 'Customer Status',
'input' => 'select',
'source' => 'StackCustomerModelAttributeSourceCustomerStatus',
'required' => true,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => false,
'is_used_in_grid' => true,
'is_visible_in_grid' => true,

]);

$attribute7 = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, $attributeCode7)
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer', 'customer_account_create', 'customer_account_edit']
]);
$attribute7->save();


also i created indexer.xml under etc of my module here is the code:



<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
<indexer id="customer_grid">
<fieldset name="customer">
<field name="customer_status" xsi:type="filterable" dataType="int"/>
</fieldset>
</indexer>



please help me and thanks in advance










share|improve this question






























    up vote
    2
    down vote

    favorite












    I have created an attribute type: select but i can't display it in the grid customer.
    the code of my customer_listing.xml



    <column name="customer_status">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="filter" xsi:type="string">select</item>
    <item name="editor" xsi:type="string">select</item>
    <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
    <item name="dataType" xsi:type="string">select</item>
    <item name="label" xsi:type="string" translate="true">Customer Status</item>
    <item name="sortOrder" xsi:type="number">190</item>
    </item>
    </argument>
    </column>


    the code of the UpgradeData.php



    $attributeCode7 = "customer_status";
    $customerSetup->addAttribute(Customer::ENTITY, $attributeCode7, [
    'type' => 'varchar',
    'label' => 'Customer Status',
    'input' => 'select',
    'source' => 'StackCustomerModelAttributeSourceCustomerStatus',
    'required' => true,
    'visible' => true,
    'user_defined' => true,
    'sort_order' => 1000,
    'position' => 1000,
    'system' => false,
    'is_used_in_grid' => true,
    'is_visible_in_grid' => true,

    ]);

    $attribute7 = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, $attributeCode7)
    ->addData([
    'attribute_set_id' => $attributeSetId,
    'attribute_group_id' => $attributeGroupId,
    'used_in_forms' => ['adminhtml_customer', 'customer_account_create', 'customer_account_edit']
    ]);
    $attribute7->save();


    also i created indexer.xml under etc of my module here is the code:



    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
    <indexer id="customer_grid">
    <fieldset name="customer">
    <field name="customer_status" xsi:type="filterable" dataType="int"/>
    </fieldset>
    </indexer>



    please help me and thanks in advance










    share|improve this question


























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have created an attribute type: select but i can't display it in the grid customer.
      the code of my customer_listing.xml



      <column name="customer_status">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="filter" xsi:type="string">select</item>
      <item name="editor" xsi:type="string">select</item>
      <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
      <item name="dataType" xsi:type="string">select</item>
      <item name="label" xsi:type="string" translate="true">Customer Status</item>
      <item name="sortOrder" xsi:type="number">190</item>
      </item>
      </argument>
      </column>


      the code of the UpgradeData.php



      $attributeCode7 = "customer_status";
      $customerSetup->addAttribute(Customer::ENTITY, $attributeCode7, [
      'type' => 'varchar',
      'label' => 'Customer Status',
      'input' => 'select',
      'source' => 'StackCustomerModelAttributeSourceCustomerStatus',
      'required' => true,
      'visible' => true,
      'user_defined' => true,
      'sort_order' => 1000,
      'position' => 1000,
      'system' => false,
      'is_used_in_grid' => true,
      'is_visible_in_grid' => true,

      ]);

      $attribute7 = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, $attributeCode7)
      ->addData([
      'attribute_set_id' => $attributeSetId,
      'attribute_group_id' => $attributeGroupId,
      'used_in_forms' => ['adminhtml_customer', 'customer_account_create', 'customer_account_edit']
      ]);
      $attribute7->save();


      also i created indexer.xml under etc of my module here is the code:



      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
      <indexer id="customer_grid">
      <fieldset name="customer">
      <field name="customer_status" xsi:type="filterable" dataType="int"/>
      </fieldset>
      </indexer>



      please help me and thanks in advance










      share|improve this question















      I have created an attribute type: select but i can't display it in the grid customer.
      the code of my customer_listing.xml



      <column name="customer_status">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="filter" xsi:type="string">select</item>
      <item name="editor" xsi:type="string">select</item>
      <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
      <item name="dataType" xsi:type="string">select</item>
      <item name="label" xsi:type="string" translate="true">Customer Status</item>
      <item name="sortOrder" xsi:type="number">190</item>
      </item>
      </argument>
      </column>


      the code of the UpgradeData.php



      $attributeCode7 = "customer_status";
      $customerSetup->addAttribute(Customer::ENTITY, $attributeCode7, [
      'type' => 'varchar',
      'label' => 'Customer Status',
      'input' => 'select',
      'source' => 'StackCustomerModelAttributeSourceCustomerStatus',
      'required' => true,
      'visible' => true,
      'user_defined' => true,
      'sort_order' => 1000,
      'position' => 1000,
      'system' => false,
      'is_used_in_grid' => true,
      'is_visible_in_grid' => true,

      ]);

      $attribute7 = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, $attributeCode7)
      ->addData([
      'attribute_set_id' => $attributeSetId,
      'attribute_group_id' => $attributeGroupId,
      'used_in_forms' => ['adminhtml_customer', 'customer_account_create', 'customer_account_edit']
      ]);
      $attribute7->save();


      also i created indexer.xml under etc of my module here is the code:



      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
      <indexer id="customer_grid">
      <fieldset name="customer">
      <field name="customer_status" xsi:type="filterable" dataType="int"/>
      </fieldset>
      </indexer>



      please help me and thanks in advance







      magento2 customer-attribute customer-grid






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 20 hours ago









      Qaisar Satti

      25.9k1255105




      25.9k1255105










      asked 20 hours ago









      Developper Magento

      42510




      42510






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          6
          down vote



          accepted










          You don't need customer_listing.xml or indexer.xml to show customer attribute in gird. these line will do it for you



              'is_used_in_grid'       => true,
          'is_visible_in_grid' => true,


          Just run the following command. This will show your column in grid.



           php bin/magento indexer:reindex


          Make sure Customer Grid index rebuilt Customer Grid index has been rebuilt successfully



          New column of customer_status will be created customer_grid_flat table






          share|improve this answer























          • thanks for your replay but i really put those two in the upgrade but nothing displayed
            – Developper Magento
            20 hours ago










          • @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
            – Qaisar Satti
            20 hours ago










          • yes i have the entry in customer_entity_varchar and the attribute is displayed in eav_attribute and when i click on add new user in BO
            – Developper Magento
            20 hours ago






          • 2




            @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
            – Vivek
            20 hours ago






          • 1




            @Vivek forgot about that thanks for reminding me.
            – Qaisar Satti
            20 hours ago











          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',
          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%2f250944%2fadd-a-custom-attribute-in-grid-customer-magento-2%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          6
          down vote



          accepted










          You don't need customer_listing.xml or indexer.xml to show customer attribute in gird. these line will do it for you



              'is_used_in_grid'       => true,
          'is_visible_in_grid' => true,


          Just run the following command. This will show your column in grid.



           php bin/magento indexer:reindex


          Make sure Customer Grid index rebuilt Customer Grid index has been rebuilt successfully



          New column of customer_status will be created customer_grid_flat table






          share|improve this answer























          • thanks for your replay but i really put those two in the upgrade but nothing displayed
            – Developper Magento
            20 hours ago










          • @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
            – Qaisar Satti
            20 hours ago










          • yes i have the entry in customer_entity_varchar and the attribute is displayed in eav_attribute and when i click on add new user in BO
            – Developper Magento
            20 hours ago






          • 2




            @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
            – Vivek
            20 hours ago






          • 1




            @Vivek forgot about that thanks for reminding me.
            – Qaisar Satti
            20 hours ago















          up vote
          6
          down vote



          accepted










          You don't need customer_listing.xml or indexer.xml to show customer attribute in gird. these line will do it for you



              'is_used_in_grid'       => true,
          'is_visible_in_grid' => true,


          Just run the following command. This will show your column in grid.



           php bin/magento indexer:reindex


          Make sure Customer Grid index rebuilt Customer Grid index has been rebuilt successfully



          New column of customer_status will be created customer_grid_flat table






          share|improve this answer























          • thanks for your replay but i really put those two in the upgrade but nothing displayed
            – Developper Magento
            20 hours ago










          • @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
            – Qaisar Satti
            20 hours ago










          • yes i have the entry in customer_entity_varchar and the attribute is displayed in eav_attribute and when i click on add new user in BO
            – Developper Magento
            20 hours ago






          • 2




            @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
            – Vivek
            20 hours ago






          • 1




            @Vivek forgot about that thanks for reminding me.
            – Qaisar Satti
            20 hours ago













          up vote
          6
          down vote



          accepted







          up vote
          6
          down vote



          accepted






          You don't need customer_listing.xml or indexer.xml to show customer attribute in gird. these line will do it for you



              'is_used_in_grid'       => true,
          'is_visible_in_grid' => true,


          Just run the following command. This will show your column in grid.



           php bin/magento indexer:reindex


          Make sure Customer Grid index rebuilt Customer Grid index has been rebuilt successfully



          New column of customer_status will be created customer_grid_flat table






          share|improve this answer














          You don't need customer_listing.xml or indexer.xml to show customer attribute in gird. these line will do it for you



              'is_used_in_grid'       => true,
          'is_visible_in_grid' => true,


          Just run the following command. This will show your column in grid.



           php bin/magento indexer:reindex


          Make sure Customer Grid index rebuilt Customer Grid index has been rebuilt successfully



          New column of customer_status will be created customer_grid_flat table







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 20 hours ago









          Vivek

          963324




          963324










          answered 20 hours ago









          Qaisar Satti

          25.9k1255105




          25.9k1255105












          • thanks for your replay but i really put those two in the upgrade but nothing displayed
            – Developper Magento
            20 hours ago










          • @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
            – Qaisar Satti
            20 hours ago










          • yes i have the entry in customer_entity_varchar and the attribute is displayed in eav_attribute and when i click on add new user in BO
            – Developper Magento
            20 hours ago






          • 2




            @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
            – Vivek
            20 hours ago






          • 1




            @Vivek forgot about that thanks for reminding me.
            – Qaisar Satti
            20 hours ago


















          • thanks for your replay but i really put those two in the upgrade but nothing displayed
            – Developper Magento
            20 hours ago










          • @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
            – Qaisar Satti
            20 hours ago










          • yes i have the entry in customer_entity_varchar and the attribute is displayed in eav_attribute and when i click on add new user in BO
            – Developper Magento
            20 hours ago






          • 2




            @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
            – Vivek
            20 hours ago






          • 1




            @Vivek forgot about that thanks for reminding me.
            – Qaisar Satti
            20 hours ago
















          thanks for your replay but i really put those two in the upgrade but nothing displayed
          – Developper Magento
          20 hours ago




          thanks for your replay but i really put those two in the upgrade but nothing displayed
          – Developper Magento
          20 hours ago












          @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
          – Qaisar Satti
          20 hours ago




          @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
          – Qaisar Satti
          20 hours ago












          yes i have the entry in customer_entity_varchar and the attribute is displayed in eav_attribute and when i click on add new user in BO
          – Developper Magento
          20 hours ago




          yes i have the entry in customer_entity_varchar and the attribute is displayed in eav_attribute and when i click on add new user in BO
          – Developper Magento
          20 hours ago




          2




          2




          @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
          – Vivek
          20 hours ago




          @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
          – Vivek
          20 hours ago




          1




          1




          @Vivek forgot about that thanks for reminding me.
          – Qaisar Satti
          20 hours ago




          @Vivek forgot about that thanks for reminding me.
          – Qaisar Satti
          20 hours ago


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f250944%2fadd-a-custom-attribute-in-grid-customer-magento-2%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

          Le Mesnil-Réaume

          Ida-Boy-Ed-Garten

          web3.py web3.isConnected() returns false always