5

In Magento 2.1.8, Customer Grid is populating from table customer_grid_flat rather than customer_entity. This is for fastest retrieval of data. But the problem is customer_grid_flat never gets populate until I manually reindex the grid using SSH.

For a quick hack I have changed the code in blow file

Line 37: vendor/magento/module-customer/Model/ResourceModel/Grid

Old Code

$mainTable = 'customer_grid_flat',

New Code

$mainTable = 'customer_entity', //'customer_grid_flat',

Now some columns are not showing data like Name, Phone, Country etc. because of missing joins with relevant tables. Can anyone please suggest any better solution.

4
  • run this command php bin/magento indexer:reindex customer_grid after check it check your indexer settings and crontab setup! Commented Mar 23, 2019 at 12:25
  • @RakeshDonga I mentioned that I can manually reindex the grid using command you mentioned. But I want automated process. Crons are working. Index status is 'valid' always. Crontab setup is correct. Commented Mar 23, 2019 at 12:31
  • 1
    @ZulqarnainAbdulJabbar have you tried Update on Save mode in admin for the cutomer grid?
    – Knight017
    Commented Mar 23, 2019 at 15:01
  • you have raised a good point. +1 for that Commented Mar 24, 2019 at 4:06

2 Answers 2

0

Step 1: Go to

System -> Index Management

Check if customer data cron is set to "Update on Save", if it is not, then set it.

enter image description here

Step 2: check if cron scheduled properly, if it is not then set it through shell.

* * * * * /usr/bin/php7.1 /var/www/Your_Project/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /var/www/Your_Project/var/log/magent$
* * * * * /usr/bin/php7.1 /var/www/Your_Project/update/cron.php >> /var/www/Your_Project/var/log/update.cron.log
* * * * * /usr/bin/php7.1 /var/www/Your_Project/bin/magento setup:cron:run >> /var/www/Your_Project/var/log/setup.cron.log

Note: You need to set location of your project and php path propely in scheduling

Step 3: Go to:

Store -> Configuration -> Advanced -> System

Expend tab: Cron (Scheduled Task)

Make sure "General Scheduled Every" is set to 1

8
  • Thank you @Shoaib for your valuable response. 'Update on Save' is not working for me. At least 22 new customers from Yesterday till now but not reflecting in the grid until I reindex the grid via reindex command. Cron setup is correct at my end. If I set customer-grid reindex to 'invalid' then cron picks it and updates the grid. Problem is, reindexer is not setting to 'invalid' after new customer creation in the system. I am thinking to do this link now to invalidate the index after new signup. Link is of Magento 1 Commented Mar 24, 2019 at 10:15
  • check table cron_schedule it will tell you the error if something happening wrong. I had faced same issue before, and got error from this table Commented Mar 24, 2019 at 13:27
  • there is no error in cron. But let me tell you that 'Update on Save' is now working. I have to run the reindex command one time manually and now customer grid is getting update on each customer save. Thank you for your help. Commented Mar 25, 2019 at 15:15
  • @ZulqarnainAbdulJabbar, I am also facing same issue. I have checked with both options "Update on Schedule" and "Update on Save". Both options are not working for me. In my case, I am creating customer programmatically which are not showing in customer grid in admin without running indexing command manually. Any idea what can be done? Commented Jun 9, 2020 at 7:49
  • 1
    @PratikNavapara you need to make sure that cron jobs are working. You need to follow all of the steps mentioned in Answer 1. Commented Jun 10, 2020 at 8:35
-1

It is the issue of indexing.

Go to the System -> Index Management. If the customer gird status is not ready then follow the below steps.

execute the following command for reindexing the customer grid.

php bin/magento indexer:reindex customer_grid

Then after clear and flush the cache using the following command

php bin/magento c:c
php bin/magento c:f

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.