Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid getByEmail calls when sending Orders and Carts to Mailchimp #468

Closed
ihor-sviziev opened this issue Nov 9, 2018 · 1 comment
Closed

Comments

@ihor-sviziev
Copy link
Contributor

Issue Description

Preconditions

1. Magento CE 2.2.6 without sample data is installed.
2. mc-magento2 1.0.30.
3. ~100k orders that we want to sync to Mailchimp

Steps to reproduce

N/A

Actual and Expected result

Right now cron job ebizmart_ecommerce runs every 5 minutes and took ~4 minutes for me. Preparing orders info takes ~3.5 minutes of that time

Additional information

During preparing orders export there is two calls to Mailchimp API for getting customer info:

  1. $customers = $api->ecommerce->customers->getByEmail($mailchimpStoreId, $order->getCustomerEmail());
  2. $customer = $api->ecommerce->customers->get($mailchimpStoreId, $order->getCustomerId(), 'email_address');

As result of 2nd requests we usually getting following error in logs:

[2018-11-09 12:14:05] MailChimpLogger.INFO: Resource Not Found for Api Call: [https://us11.api.mailchimp.com/3.0/ecommerce/stores/c165314426294f1f4aff49977407e962/customers/353087?fields=email_address] using method [GET]
	Detail: [The requested resource could not be found.]
	Params:
		{"fields":"email_address"}
 [] []

Usually these requests took ~0.2 seconds each.

How it can be improved:

  1. Create table with following info - mailchimp store id, mailchimp customer id and email.
  2. During customers export - export customers that are needed for orders at first, then fill up this table
  3. When exporting customers - export customers that required for orders sync at first
  4. during orders export - use data from table for getting this info.
@gonzaloebiz
Copy link
Collaborator

Hi @ihor-sviziev

thanks for your feedback.
We are open to PR

Best

@gonzaloebiz gonzaloebiz self-assigned this Feb 22, 2019
@gonzaloebiz gonzaloebiz added this to the 1.x.34 milestone Feb 22, 2019
gonzaloebiz added a commit that referenced this issue Feb 22, 2019
gonzaloebiz added a commit that referenced this issue Feb 22, 2019
gonzaloebiz added a commit that referenced this issue Feb 22, 2019
@gonzaloebiz gonzaloebiz changed the title Orders sync is slow with big amount of data Avoid getByEmail calls when sending Orders and Carts to Mailchimp Feb 22, 2019
gonzaloebiz added a commit that referenced this issue Feb 22, 2019
gonzaloebiz added a commit that referenced this issue Feb 22, 2019
gonzaloebiz added a commit that referenced this issue Feb 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants