Magento2: Magento 2.2.0rc23: Customer Grid Indexer not working

Created on 11 Sep 2017  路  71Comments  路  Source: magento/magento2

The Customer Grid Indexer doesn't work, when reindexing via CLI.

Preconditions

local - Docker Container:

  1. PHP 7.0 and 7.1 (default)
  2. MySQL 5.5.5-10.1.25-MariaDB
  3. Magento 2.2.0rc23

Steps to reproduce

  1. Manage to upgrade your store via composer from 2.1.7 to 2.2.0rc23 (good luck here!)
  2. Run setup:upgrade and fix all problems, which occur during the process until it runs without problems
  3. Run reindex of Cutomer Grid (indexer:reindex customer_grid) via CLI command

Expected result

  1. At this stage only problems occuring, which are caused by plugins from extern modules using deprecated functions, classes, etc.)

Actual result

m220rc23_indexer_customer_grid

Fixed in 2.2.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.1.x Reproduced on 2.2.x

Most helpful comment

Here ist the patch that solves the problem. Though I don't really get why Magento did leave this function out. And if you look at the content of the MDVA-4538_EE_2.1.4_v2 patch, it seems that the 2.1.4 EE version of Magento already used the same indexer logic as CE 2.2 uses now.

It would be really interesting to know what the thought behind that different implementation was.

fix_customer_grid_indexer_add_missing_function 2.txt

All 71 comments

Same issue on 2.1.8 and 2.1.7

@jhruehl thank you for your report. Unfortunately, we can't guarantee that 3-rd party modules will work with newest Magento versions correctly if they depend on internal Magento code and not on code which marked with @api.
Our team works hard on keeping further Magento versions from incompatible changes, but that's not always possible. If you'd like to update your issue, please reopen it.

Nonsense. There is no third party module involved. Checked it by deactivating them all. And even the stack trace makes it quite obvious that its not a third party module. And the Customer Grid Indexer works just fine until updating to 2.2.0rc3.0.

So my guess is that you changed the Customer Grid Reindexer process in a way and forgot about Customer Attributes, which have the 'visible in grid' option set. Because that is the most probable reason why the Customer Grid Indexer calls the Attribute Handler.

@jhruehl yeah, I was wondering how it is identified as a third-party module issue from the screenshot as well. Is the issue still reproducible for you on latest 2.2.0-preview branch?

@orlangur Yes, it is. But I'm going to try to reproduce it now in our vanilla m2.2.0rc3 store test server by adding a customer attribute with 'visible in grid' set to yes.

Sadly I couldn't reproce the Cutomer Grid Indexer problem with just adding the same attribute to the vanilla store we have already implemented. So I need to investigate further by debugging. But it could be that the massive difference between our productive customer data (where some incoherence snuggled in over the years) and the few (actually two customers), which are set in the vanilla installation.

There is a patch for this problem MDVA-4538_EE_2.1.4_v2
Which you can request through partner portal

@VoidWalker EE_2.1.4 does not seem to be suitable for 2.2.0rc23. I believe such an old patch (2.1.4 - 2.1.9) is already included in 2.2.0.

I was actually able to reproduce it in our vanilla m2.2.0rc3.0 store. In my first run, I didn't set 'is_used_in_grid'. Going to open a new Issue, because otherwise it probably gets ignored.

@jhruehl could you check the latest 2.2.0-preview please? I'll reopen an issue for you if reproducible.

@orlangur Isn't the 2.2.0rc3.0 Version the latest Preview?

It is the last RC probably, but the branch was updated after that: https://github.com/magento/magento2/tree/2.2.0-preview

Just looked at the problematic classes in the 2.2.0 and the 2.2.1-preview. They haven't been updated since then.
'Magento\Customer\Model\Indexer\Source' and '/lib/internal/Magento/Framework/Indexer/Handler/AttributeHandler'

So I don't really see the point to invest a lot of time into an update process to a preview branch, if the function addAttributeToSelect() is still missing in the Source class and still called in the AttributeHandler class.

So even the folders '/lib/internal/Magento/Framework/Indexer/' and 'Magento/Customer/Model/Indexer/' were not updated for a month, which leads to the conclusion that going into a probably not composer supported update will be just a waste of time leading to the same results.

Sure, makes sense to me.

@magento-engcom-team please provide some insight on https://github.com/magento/magento2/issues/10838#issuecomment-330536123, looks like the issue is reproducible on vanilla installation as well.

@orlangur Thanks a lot for your help.

@magento-engcom-team The key to reproduce the problem is setting up a customer eav attribute, which has the 'is_used_in_grid' option set to 1.

Here is the latest command line stack trace from our vanilla magento 2.2.0rc3.0 installation:
magento2_vanilla@d2372a84f1f8:/var/www/users/magento2_vanilla/src/scripts$ ./magento.sh indexer:reindex customer_grid

Fatal error: Uncaught Error: Call to undefined method Magento\Customer\Model\Indexer\Source::addAttributeToSelect() in /mnt/host/projects/clients/magento2-vanilla/src/www/lib/internal/Magento/Framework/Indexer/Handler/AttributeHandler.php:38
Stack trace:

0 /mnt/host/projects/clients/magento2-vanilla/src/www/lib/internal/Magento/Framework/Indexer/Action/Base.php(310): Magento\Framework\Indexer\Handler\AttributeHandler->prepareSql(Object(Magento\Customer\Model\Indexer\Source), 'e', Array)

1 /mnt/host/projects/clients/magento2-vanilla/src/www/lib/internal/Magento/Framework/Indexer/Action/Entity.php(26): Magento\Framework\Indexer\Action\Base->createResultCollection()

2 /mnt/host/projects/clients/magento2-vanilla/src/www/lib/internal/Magento/Framework/Indexer/Action/Base.php(179): Magento\Framework\Indexer\Action\Entity->prepareDataSource(Array)

3 /mnt/host/projects/clients/magento2-vanilla/src/www/lib/internal/Magento/Framework/Indexer/Action/Base.php(189): Magento\Framework\Indexer\Action\Base->execute()

4 /mnt/host/pro in /mnt/host/projects/clients/magento2-vanilla/src/www/lib/internal/Magento/Framework/Indexer/Handler/AttributeHandler.php on line 38

@jhruehl @orlangur thank you for research. we will take a look at this

@jhruehl it would be great if you can submit pull request if you know how to fix the issue

@okobchenko The solution seems not be just a simple fix, but looking at the code structure a public function addAttributeToSelect() needs to be implemented in the Magento\Customer\Model\Indexer\Source class as there a similar functions like addFieldToSelect() implemented by passing the requests to other injected classes, which have the needed functionality already implemented.

Though it seems that the by dependency injection reachable addAttributeToSelect() functions don't work without further adjustments in that case, because I tried to simply copy them into the problemtatic Source class without real adjustments and this mostly lead to the attribute not being found, because the right tables to join with weren't addressed.

But it seems a good approach would be similar to Magento/Catalog/Model/ResourceModel/Category/Flat/Collection::addAttributeToSelect(), but as I already stated needs to be adjusted to join with the right tables and probably some more.

@okorshenko I feel like it make sense to repeat. There is a patch for this issue MDVA-4538_EE_2.1.4_v2
It might be not totally suitable fir 2.2.* but it shows the fix idea

Here ist the patch that solves the problem. Though I don't really get why Magento did leave this function out. And if you look at the content of the MDVA-4538_EE_2.1.4_v2 patch, it seems that the 2.1.4 EE version of Magento already used the same indexer logic as CE 2.2 uses now.

It would be really interesting to know what the thought behind that different implementation was.

fix_customer_grid_indexer_add_missing_function 2.txt

@jhruehl I'm not sure how to apply your patch - I have no /vendor/magento/module-customer directory.
Could you please explain how to apply your patch? Thanks!

@epicglows I guess you have the Magento modules in the app/code folder then. The given Source class in your installation should be in the app/code/Magento/Customer/Model/Indexer folder, I guess. Just add the addAttributeToSelect($fieldname, $alias = null) function to the source class as given in the patch file, empty the generated folder, clean/flush the cache, reset the stuck indexer and it should work.

And if you don't find it, just look at the stack trace given, when you run the 'indexer:reindex customer_grid' command in your terminal.

We seem to be running into the same issue, but this already happens during the database migration scripts when upgrading from 2.1.9 to 2.2.0 (Magento Cloud project):

$ bin/magento setup:upgrade
...
Upgrading data..
Module 'Magento_Eav':
Module 'Magento_AdvancedPricingImportExport':
Module 'Magento_Rule':
Module 'Magento_Customer':
Upgrading data.. PHP Fatal error:  Uncaught Error: Call to undefined method Magento\Customer\Model\Indexer\Source::addAttributeToSelect() in vendor/magento/framework/Indexer/Handler/AttributeHandler.php:38
Stack trace:
#0 vendor/magento/framework/Indexer/Action/Base.php(310): Magento\Framework\Indexer\Handler\AttributeHandler->prepareSql(Object(Magento\Customer\Model\Indexer\Source), 'e', Array)
#1 vendor/magento/framework/Indexer/Action/Entity.php(26): Magento\Framework\Indexer\Action\Base->createResultCollection()
#2 vendor/magento/framework/Indexer/Action/Base.php(179): Magento\Framework\Indexer\Action\Entity->prepareDataSource(Array)
#3 vendor/magento/framework/Indexer/Action/Base.php(189): Magento\Framework\Indexer\Action\Base->execute()
#4 vendor/magento/module-indexer/Model/Indexer.php(412): Magento\Framework\Indexer\Action\Base-> in vendor/magento/framework/Indexer/Handler/AttributeHandler.php on line 38

Fatal error: Uncaught Error: Call to undefined method Magento\Customer\Model\Indexer\Source::addAttributeToSelect() in vendor/magento/framework/Indexer/Handler/AttributeHandler.php:38
Stack trace:
#0 vendor/magento/framework/Indexer/Action/Base.php(310): Magento\Framework\Indexer\Handler\AttributeHandler->prepareSql(Object(Magento\Customer\Model\Indexer\Source), 'e', Array)
#1 vendor/magento/framework/Indexer/Action/Entity.php(26): Magento\Framework\Indexer\Action\Base->createResultCollection()
#2 vendor/magento/framework/Indexer/Action/Base.php(179): Magento\Framework\Indexer\Action\Entity->prepareDataSource(Array)
#3 vendor/magento/framework/Indexer/Action/Base.php(189): Magento\Framework\Indexer\Action\Base->execute()
#4 vendor/magento/module-indexer/Model/Indexer.php(412): Magento\Framework\Indexer\Action\Base-> in vendor/magento/framework/Indexer/Handler/AttributeHandler.php on line 38

The workaround mentioned by @jhruehl by adding the addAttributeToSelect method to the Magento\Customer\Model\Indexer\Source class seems to fix the issue so it might be the correct solution.

@okorshenko: I don't think it's up to the community to fix this, database migration scripts in between Magento versions should be really stable out of the box. So it's best if one of the core devs could take a look at this I think.
Would be great if this could get fixed in 2.2.1

I haven't tried to create an easy reproducible case yet, but maybe @jhruehl already has? Might indeed have something to do with the is_used_in_grid flag set to 1 for customer attributes like @jhruehl mentions, but haven't verified this.

@hostep Yes. I reproduced it already in a vanilla store 2.2.0rc3 installation with demo data as mentioned above somewhere :) . The culprit is a customer EAV attribute with 'is_used_in_grid' set to yes. Adjusted the attribute in the database directly to pin point the cause. With 'is_used_in_grid' set to no, there are no problems.

The patch I posted here, is actually derived from the MDVA-4538_EE_2.1.4_v2 patch proposed by @VoidWalker.

I've also encountered this issue using 2.2.0, after upgrading from 2.1.9 (in my case using https://marketplace.magento.com/commerceextensions-module-hide-product-price.html )

It's doing this in it's setup:

  $customerSetup->addAttribute(Customer::ENTITY, 'is_approved', [
            'type' => 'int',
            'label' => 'Approved',
            'input' => 'select',
            'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
            'value' => 0,
            'default' => 0,
            'required' => false,
            'visible' => false,
            'user_defined' => true,
            'sort_order' => 90,
            'position' => 90,
            'system' => false,
            'is_used_in_grid' => true,
            'is_visible_in_grid' => true,
            'is_filterable_in_grid' => true,
            'is_searchable_in_grid' => true,
        ]);

Which gives the following error with indexing:

PHP Fatal error:  Uncaught Error: Call to undefined method Magento\Customer\Model\Indexer\Source::addAttributeToSelect() in /var/www/magento2/vendor/magento/framework/Indexer/Handler/AttributeHandler.php:38
Stack trace:
#0 /var/www/magento2/vendor/magento/framework/Indexer/Action/Base.php(310): Magento\Framework\Indexer\Handler\AttributeHandler->prepareSql(Object(Magento\Customer\Model\Indexer\Source), 'e', Array)
#1 /var/www/magento2/vendor/magento/framework/Indexer/Action/Entity.php(26): Magento\Framework\Indexer\Action\Base->createResultCollection()
#2 /var/www/magento2/vendor/magento/framework/Indexer/Action/Base.php(179): Magento\Framework\Indexer\Action\Entity->prepareDataSource(Array)
#3 /var/www/magento2/vendor/magento/framework/Indexer/Action/Base.php(189): Magento\Framework\Indexer\Action\Base->execute()
#4 /var/www/magento2/vendor/magento/module-indexer/Model/Indexer.php(412): Magento\Framework\Indexer\Action\Base->executeFull()
#5 /var/www/magento2/vendor/mage in /var/www/magento2/vendor/magento/framework/Indexer/Handler/AttributeHandler.php on line 38

Setting the is_used_in_grid option to false in the database makes the indexer run again, but obviously doesn't include the attribute in the grid anymore.. (show empty). This worked fine in 2.1.9

This issue is incredible because It is the result of a fake configuration of the file:

module-customer/etc/indexer.xml

In fact the bug is the line 14:

<fieldset name="customer" source="Magento\Customer\Model\Indexer\Source"

must be changed in

<fieldset name="customer" source="Magento\Customer\Model\ResourceModel\Customer\Collection"

So the problem is solved.

@selusi

The file Magento\Customer\Model\Indexer\Source doesn't exists.

What's this then?
https://github.com/magento/magento2/blob/2.2.0/app/code/Magento/Customer/Model/Indexer/Source.php

I apologize because in the previous comment I indicated that the
Magento \ Customer \ Model \ Indexer \ Source.php file did not exist, while it is actually alive and well.

However, by modifying the indexer.xml file the index rebuilding work fine.

Alternativly is possible add the below function to the file Source.php:

public function addAttributeToSelect($attribute, $joinType = false)
{
    $this->customerCollection->addAttributeToSelect($attribute, $joinType);
    return $this;
}

I tested both methods on my test site.

@jhruehl, thank you for your report.
We've created internal ticket(s) MAGETWO-81802 to track progress on the issue.

FYI, we have updated our patch repository to include @jhruehl's patch for automatic Composer application: https://github.com/ripenecommerce/magento2-patches

I believe there is another method missing in the Source.php file for Magento 2.2.0:

    public function joinAttribute($alias, $attribute, $bind, $filter = null, $joinType = 'inner', $storeId = null)
    {
        return $this->customerCollection->joinAttribute($alias, $attribute, $bind, $filter, $joinType, $storeId);
    }

I determined this from that fact that I also received the MDVA-4538_EE patch now.
In that patch, the entire Source.php file is being added, because it didn't exist in Magento 2.1
But in Magento 2.2, the file already exists, it was introduced by https://github.com/magento/magento2/commit/6d98e2a57059ef75d9d0dd0585b84bb33953e107

If I compare the Source class from the patch with the one which is now included in Magento 2.2.0, there are 2 methods missing in the one from Magento 2.2.0:

  • addAttributeToSelect
  • joinAttribute

It was already shown that the addAttributeToSelect method is needed for the database migration scripts from 2.1.9 to 2.2.0 and to be able to reindex the customer grid.
But not sure if the joinAttribute can be used somehow.

@okorshenko: can you try to figure out how and why this happened? It feels to me that these two methods should be included, I don't think the community can help with figuring this out since we don't have access to your internal knowledge, so the SQUASHTOBERFEST label feels wrong here?

Hi @hostep we will take a look at this. Thank you

Can confirm all above communications from @hostep & @selusi. Having same issue in 2.2.1 with custom attribute created.

I have this in UpgradeData.php

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

            //customer attribute cs_cid
            $customerSetup->addAttribute(
                \Magento\Customer\Model\Customer::ENTITY,
                'cs_cid',
                [
                    'type' => 'text',
                    'label' => 'Customernumber',
                    'input' => 'text',
                    'required' => false,
                    'visible' => true,
                    'user_defined' => false,
                    'sort_order' => 1000,
                    'position' => 1000,
                    'system' => 0,
                    'default_value' => 0,
                    'is_used_in_grid' => true,
                    'is_visible_in_grid' => true,
                    'is_filterable_in_grid' => true,
                    'is_searchable_in_grid' => true,
                ]
            );

            $attribute = $customerSetup
                ->getEavConfig()
                ->getAttribute(\Magento\Customer\Model\Customer::ENTITY, 'cs_cid')
                ->addData([
                    'attribute_set_id' => $attributeSetId,
                    'attribute_group_id' => $attributeGroupId,
                    'used_in_forms' => ['adminhtml_customer'],
                ]);

            $attribute->save();

When you run the indexer after this, you'll get the following error PHP Fatal error: Uncaught Error: Call to undefined method Magento\Customer\Model\Indexer\Source::addAttributeToSelect()

When you disable is_used_in_grid, is_visible_in_grid, is_filterable_in_grid, is_searchable_in_grid the reindexer is working again.

Maybe this can help in debugging?

Hello. We have the same problem with Magento Cloud Edition 2.2.0 and 2.2.1

Please check you
vendor/magento/module-customer/etc/indexer.xml
Arround line no 14 Find

Replace with

@jhruehl Thanks for your pointer. The patch fixed exactly the same issue I was facing. I am at Magento 2.2.1 CE. So, that means fix is still not released in Magento 2.2.1. Hope it would be released in next release. It is a critical fix.

It seems that the customer_grid_flat is not updated automatically since I've updated 2.1.8 to 2.1.9. Indexing using the CLI works however. Is this also related to this issue?

I upgraded to 2.2.2 EE today and the bug is still in place.

mageconf

@dzianis-yurevich thank you for joining. Please accept team invitation here and self-assign the issue.

mageconf

@sneig thank you for joining. Please accept team invitation here and self-assign the issue.

@dverkade found the issue why our customer grid doesn't update ;)

Hi, guys, I was facing this issue too if I add a customer attribute from backend then indexer is unable to reindex customer grid but I changed the attribute type from varchar to static in eav table then everything works properly! goo look.

Thanks @cotardo18 it works for me.
I had to modify all custom attributes not only varchar (int, bool etc...)

I would like to add that all custom customers attributes with "is_user_defined" set to true are not visible in the backoffice, I had to modify it to false.

Erf, weird Magento behavior

I confirm this happens on CE 2.2.1
I temporary solved this problem by disabling my custom attributes on grid:
'is_used_in_grid' => false, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => false,

@agata-maksymiuk I agree with you, having an extra attribute on customer's grid is possible only if the attribute type is changed in eav table to static

@pfortin-expertime answer from @selusi is the good one! if you take my answer you won't be able to save data

Just FYI: I've got confirmation from the Magento Cloud support that this issue should get fixed in Magento 2.2.4

The fix should be:

diff --git a/vendor/magento/framework/Indexer/Handler/AttributeHandler.php b/vendor/magento/framework/Indexer/Handler/AttributeHandler.php
index 94f34ec..4b74ce5 100644
--- a/vendor/magento/framework/Indexer/Handler/AttributeHandler.php
+++ b/vendor/magento/framework/Indexer/Handler/AttributeHandler.php
@@ -35,7 +35,7 @@ class AttributeHandler implements HandlerInterface
                 'left'
             );
         } else {
-            $source->addAttributeToSelect($fieldInfo['origin'], 'left');
+            $source->addFieldToSelect($fieldInfo['origin'], 'left');
         }
     }
 }

Looks like there is a pending PR which should fix this: https://github.com/magento/magento2/pull/12729

Just updated to Magento 2.2.3 CE and it's not fixed. Had to apply my patch to make the customer grid indexer work again.
`scripts/magento.sh indexer:reindex customer_grid

Fatal error: Uncaught Error: Call to undefined method Magento\Customer\Model\Indexer\Source::addAttributeToSelect() in /mnt/host/projects/clients/qualipet/src/www/vendor/magento/framework/Indexer/Handler/AttributeHandler.php:38
Stack trace:

0 /mnt/host/projects/clients/qualipet/src/www/vendor/magento/framework/Indexer/Action/Base.php(310): Magento\Framework\Indexer\Handler\AttributeHandler->prepareSql(Object(Magento\Customer\Model\Indexer\Source), 'e', Array)

1 /mnt/host/projects/clients/qualipet/src/www/vendor/magento/framework/Indexer/Action/Entity.php(26): Magento\Framework\Indexer\Action\Base->createResultCollection()

2 /mnt/host/projects/clients/qualipet/src/www/vendor/magento/framework/Indexer/Action/Base.php(179): Magento\Framework\Indexer\Action\Entity->prepareDataSource(Array)

3 /mnt/host/projects/clients/qualipet/src/www/vendor/magento/framework/Indexer/Action/Base.php(189): Magento\Framework\Indexer\Action\Base->execute()

4 /mnt/host/projects/clients/qualipet/src/www/vendor/magento/module-indexer/Model/Ind in /mnt/host/projects/clients/qualipet/src/www/vendor/magento/framework/Indexer/Handler/AttributeHandler.php on line 38`

@jhruehl: I'm pretty sure the fix is scheduled for 2.2.4 (see my latest comment), 2.2.3 only fixes security issues, no other bug fixes as far as I can see.

Here's the patch again for everyone, who still needs a fix, because they have a custom customer attribute, which is used in grid, in their store.

fix_customer_grid_indexer_add_missing_function.txt

@hostep Doesn't really matter, if the issue is flagged with 'fixed in 2.2.x'. If they flagged the issue to be fixed, but the fix isn't even given in an update afterwards, the flag is quite misleading, isn't it? Then they should use a 'fixed in 2.2.4' flag and given that, I wouldn't even have reported the error. Again.

A Patch in the Core Files is not best idea. You can made a module with this patch.

Yesterday, i made a moudle quickly, to fix this problem. You can find it on composer require vitd/m2_fixes.

Do not forget do following:

  • bin/magento setup:upgrade
  • bin/magento setup:di:compile
  • bin/magento cache:clean
  • bin/magento cache:flush
  • bin/magento setup:static-content:deploy <languages with spaces> -f (on cli will not content deployed in all store used languages, you can use alternative change the deploy:mode:set (developer, production) and back, this work proper).

You can modifying the module on your own wish or you can write an issue ticket on the repo page.

I hope this will help any one :)

Still broken in 2.2.3 Commerce.

Yes!, I have downloaded and upgrade magento 2.2.2 to 2.2.3. but still issue is not fixed from core.

I can confirm this issue has been fixed in Magento Open Source 2.2.4.

In my case when i create a custom customer attribute and "Add to Column Options" to yes in magento2 EE. i got this error when i try reindex.
So that i set this field value to no. and its working fine.

Magento Team needs to taking care it.

i have add this function public function addAttributeToSelect($attribute, $joinType = false) { $this->customerCollection->addAttributeToSelect($attribute, $joinType); return $this; } in app/code/Magento/Customer/Model/Indexer/Source.php
but got an error while re indexing.
PHP Fatal error: Uncaught Error: Call to undefined method Magento\Customer\Model\Indexer\Source::addAttributeToSelect() in /var/www/html/ncsmokehouse/vendor/magento/framework/Indexer/Handler/AttributeHandler.php:38
what m i do ?

i have add this function public function addAttributeToSelect($attribute, $joinType = false) { $this->customerCollection->addAttributeToSelect($attribute, $joinType); return $this; } in app/code/Magento/Customer/Model/Indexer/Source.php
but got an error while re indexing.
PHP Fatal error: Uncaught Error: Call to undefined method Magento\Customer\Model\Indexer\Source::addAttributeToSelect() in /var/www/html/ncsmokehouse/vendor/magento/framework/Indexer/Handler/AttributeHandler.php:38
what m i do ?

Before updating the index you have to launch the following commands:

php bin/magento setup:upgrade
php bin/magento setup:di:compile

i have add this function public function addAttributeToSelect($attribute, $joinType = false) { $this->customerCollection->addAttributeToSelect($attribute, $joinType); return $this; } in app/code/Magento/Customer/Model/Indexer/Source.php
but got an error while re indexing.
PHP Fatal error: Uncaught Error: Call to undefined method Magento\Customer\Model\Indexer\Source::addAttributeToSelect() in /var/www/html/ncsmokehouse/vendor/magento/framework/Indexer/Handler/AttributeHandler.php:38
what m i do ?

Before updating the index you have to launch the following commands:

php bin/magento setup:upgrade
php bin/magento setup:di:compile

i already launch these commands. but no success

I apologize because in the previous comment I indicated that the
Magento \ Customer \ Model \ Indexer \ Source.php file did not exist, while it is actually alive and well.

However, by modifying the indexer.xml file the index rebuilding work fine.

Alternativly is possible add the below function to the file Source.php:

public function addAttributeToSelect($attribute, $joinType = false)
{
    $this->customerCollection->addAttributeToSelect($attribute, $joinType);
    return $this;
}

I tested both methods on my test site.

m follow this but got an error . how can i resolve ?

@hafizjee, the correct fix is this one: https://github.com/magento/magento2/commit/7759827ff277157d3cf1ae93b1392a73bc2538de

If you use composer, you can follow this guide to install this as a patch on top of your installation: https://support.magento.com/hc/en-us/articles/360005484154-Create-a-patch-for-a-Magento-2-Composer-installation-from-a-GitHub-commit

Or you can just upgrade to Magento 2.2.4 or higher where this fix is included.

@hafizjee
You can try to delete the folders:
generated\code
var\cache
and then launch:

php bin/magento setup:upgrade
php bin/magento setup:di:compile

The error code leaves no doubt of interpretation. The application does not find the required method, so either you copied the code to the wrong file or you did not completely delete the cache.
Another possible cause could be the permissions assigned to the folders that could prevent the proper rewriting of the cache.

Here's the patch again for everyone, who still needs a fix, because they have a custom customer attribute, which is used in grid, in their store.

fix_customer_grid_indexer_add_missing_function.txt

work for me

I'm experiencing this problem on my Magento 2.1.12 as well. Is there any fix for the Magento 2.1.* ? Because the fixes mentioned earlier are all applying for Magento 2.2+

Was this page helpful?
0 / 5 - 0 ratings