3

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.

  • run this command php bin/magento indexer:reindex customer_grid after check it check your indexer settings and crontab setup! – Rakesh Donga Mar 23 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. – Zulqarnain Abdul Jabbar Mar 23 at 12:31
  • 1
    @ZulqarnainAbdulJabbar have you tried Update on Save mode in admin for the cutomer grid? – Knight017 Mar 23 at 15:01
  • you have raised a good point. +1 for that – Shoaib Munir Mar 24 at 4:06
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

  • 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 – Zulqarnain Abdul Jabbar Mar 24 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 – Shoaib Munir Mar 24 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. – Zulqarnain Abdul Jabbar Mar 25 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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