0

I am trying to add custom attribute column in admin customer grid in Magento 2 but I got below error.

main.CRITICAL: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ip_country' in 'order clause'

2 Answers 2

0

if the column is an action column please add below code

<actionsColumn name="actions" class="namespace\firstname\Ui\Component\Listing\Action">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="resizeEnabled" xsi:type="boolean">false</item>
            <item name="resizeDefaultWidth" xsi:type="string">107</item>
            <item name="indexField" xsi:type="string">ip_country</item>
        </item>
    </argument>
</actionsColumn>

if this an normal column add the below code.

<column name="ip_country">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="filter" xsi:type="string">text</item>
            <item name="sorting" xsi:type="string">asc</item>
            <item name="label" xsi:type="string" translate="true">IP Country</item>
        </item>
    </argument>
</column>

Try these codes and check once

0

Why do you need to add column programmatically when it can be managed via setting or while creating the custom customer attribute. Login to admin, Go to Stores->Attributes->Customer->search for your customer attribute and set Add to Column Options to Yes (Select "Yes" to add this attribute to the list of column options in the customer grid.)

Hope this helps!

3
  • I am using magneto 2.2 . In this version, we didn't find customer in stores tab.
    – Aish
    Commented Feb 5, 2018 at 8:42
  • I have given you the path for Magento 2.2 only, its Stores->Attributes->Customer.
    – Shireen N
    Commented Feb 5, 2018 at 8:44
  • I cant see Stores->Attributes->Customer in 2.2.2 Commented Feb 5, 2018 at 14:55

Your Answer

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

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