mc-magento2
mc-magento2 copied to clipboard
Long delay loading 75 Mailchimp Stores
Long delay loading 75 Mailchimp Stores
Long delay (almost a minute) loading 75 Mailchimp Stores
Issue Description
Preconditions
1. Magento CE 2.3.X
2. Mailchimp extension version: 102.3.41
3. Having at least 75 Mailchimp Stores created in Magento.
Steps to reproduce
Open Mailchimp => Mailchimp Stores
Actual and Expected result
Expected result:
Load 75 Mailchimp Stores in few seconds or a second's fraction
Actual result:
Load 75 Mailchimp Stores delays almost a minute (50 seconds)
Additional information
Currently the method which fills the collection of Mailchimp Stores is loadStores() from: loadStores()
I thought to a possible solution about this issue.
My idea consist to avoid to truncate mailchimp_stores table and refill it every time admin users browse mailchimp_stores grid. Instead of it, my solution could remove only stores that are changed from last time users browsed listing. In this way loadStores function will be more light because the calls to mailchimp service will be executed only for stores that are changed in the while.
To apply this logic I will introduce 2 new parameters into core_config table:
1- mailchimp/general/mailchimp_last_grid_visited
This config data has global (or defualt) scope. And It will updated every time that function loadStores will be called. In this way I know last time that mailchimp_store table has been reloaded.
2- mailchimp/general/mailchimp_last_config_save
This config data has website/store view scope, and every time admin users change mailchimp configuration from (Stores > Configuration > Mailchimp > Malchimp ) related to one website/store view, this config data is updated.
Now I have last time that mailchimp_store table has been reload and mailchimp/general/mailchimp_last_config_save that tell me, for every website/store view, when i saved mailchimp configuration. If I have this 2 parameters I can avoid to truncate all stores in mailchimp_store table and remove only stores where I found that
mailchimp/general/mailchimp_last_config_save > mailchimp/general/mailchimp_last_grid_visited