Add a custom attribute in grid customer magento 2












3














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





























    3














    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



























      3












      3








      3







      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 Nov 22 '18 at 10:55









      Qaisar Satti

      26.3k1255106




      26.3k1255106










      asked Nov 22 '18 at 10:37









      Developper Magento Developper Magento

      46310




      46310






















          1 Answer
          1






          active

          oldest

          votes


















          6














          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
            Nov 22 '18 at 10:51










          • @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
            – Qaisar Satti
            Nov 22 '18 at 10:55










          • 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
            Nov 22 '18 at 10:59






          • 2




            @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
            – Vivek
            Nov 22 '18 at 11:06






          • 1




            @Vivek forgot about that thanks for reminding me.
            – Qaisar Satti
            Nov 22 '18 at 11:07











          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%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









          6














          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
            Nov 22 '18 at 10:51










          • @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
            – Qaisar Satti
            Nov 22 '18 at 10:55










          • 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
            Nov 22 '18 at 10:59






          • 2




            @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
            – Vivek
            Nov 22 '18 at 11:06






          • 1




            @Vivek forgot about that thanks for reminding me.
            – Qaisar Satti
            Nov 22 '18 at 11:07
















          6














          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
            Nov 22 '18 at 10:51










          • @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
            – Qaisar Satti
            Nov 22 '18 at 10:55










          • 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
            Nov 22 '18 at 10:59






          • 2




            @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
            – Vivek
            Nov 22 '18 at 11:06






          • 1




            @Vivek forgot about that thanks for reminding me.
            – Qaisar Satti
            Nov 22 '18 at 11:07














          6












          6








          6






          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 Nov 22 '18 at 10:59









          Vivek

          1,301324




          1,301324










          answered Nov 22 '18 at 10:47









          Qaisar SattiQaisar Satti

          26.3k1255106




          26.3k1255106












          • thanks for your replay but i really put those two in the upgrade but nothing displayed
            – Developper Magento
            Nov 22 '18 at 10:51










          • @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
            – Qaisar Satti
            Nov 22 '18 at 10:55










          • 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
            Nov 22 '18 at 10:59






          • 2




            @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
            – Vivek
            Nov 22 '18 at 11:06






          • 1




            @Vivek forgot about that thanks for reminding me.
            – Qaisar Satti
            Nov 22 '18 at 11:07


















          • thanks for your replay but i really put those two in the upgrade but nothing displayed
            – Developper Magento
            Nov 22 '18 at 10:51










          • @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
            – Qaisar Satti
            Nov 22 '18 at 10:55










          • 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
            Nov 22 '18 at 10:59






          • 2




            @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
            – Vivek
            Nov 22 '18 at 11:06






          • 1




            @Vivek forgot about that thanks for reminding me.
            – Qaisar Satti
            Nov 22 '18 at 11:07
















          thanks for your replay but i really put those two in the upgrade but nothing displayed
          – Developper Magento
          Nov 22 '18 at 10:51




          thanks for your replay but i really put those two in the upgrade but nothing displayed
          – Developper Magento
          Nov 22 '18 at 10:51












          @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
          – Qaisar Satti
          Nov 22 '18 at 10:55




          @DevelopperMagento did you run the command? make sure your you have entry in table eav_attribute and respectively customer_eav_attribute
          – Qaisar Satti
          Nov 22 '18 at 10:55












          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
          Nov 22 '18 at 10:59




          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
          Nov 22 '18 at 10:59




          2




          2




          @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
          – Vivek
          Nov 22 '18 at 11:06




          @DevelopperMagento, Did you select to show your custom attribute collumn ??!! From all collumn list at customer Grid.
          – Vivek
          Nov 22 '18 at 11:06




          1




          1




          @Vivek forgot about that thanks for reminding me.
          – Qaisar Satti
          Nov 22 '18 at 11:07




          @Vivek forgot about that thanks for reminding me.
          – Qaisar Satti
          Nov 22 '18 at 11:07


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%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

          Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

          ts Property 'filter' does not exist on type '{}'

          mat-slide-toggle shouldn't change it's state when I click cancel in confirmation window