veda-consulting-company / uk.co.vedaconsulting.mailchimp

Other
22 stars 43 forks source link

Sync Mailchimp Contacts To Civi stuck at Updating contacts in CiviCRM #210

Closed cmmadmin closed 7 years ago

cmmadmin commented 8 years ago

I am attempting to run Mailings > 'Sync Mailchimp Contacts To Civi' and it is getting stuck at this stage:

[Executed: List 1 CMM Mailchimp: Fetching data from CiviCRM]

I have max_execution_time in php.ini set to 900000. I have let it run overnight and it is still stuck.

There are 9,630 contacts in my Mailchimp list which contains several interesting groups. I have created an empty group and child groups in CiviCRM which I am attempting to sync the Mailchimp contacts into. Most of these contacts already exist in CiviCRM in other groups, but the most up to date data is in Mailchimp, so I thought pulling it in from Mailchimp was the best approach.

I was getting several of these errors (in the CiviCRM log file) but I resolved them by merging the contacts in CiviCRM.

[info] Mailchimp Pull/Webhook: Multiple contacts found for the email address xyz@gmail.com [info] Mailchimp Pull/Webhook: Multiple contacts found for the email address which is not primary abc@gmail.com

Now, I just see this in the CiviCRM log file:

Apr 21 14:41:10 [info] Running task: Preparing queue for List 1 CMM Mailchimp Apr 21 14:41:11 [info] Running task: List 1 CMM Mailchimp: Fetching data from Mailchimp (can take a mo) Apr 21 14:41:47 [info] Running task: List 1 CMM Mailchimp: Fetching data from CiviCRM Apr 21 14:41:56 [info] Running task: List 1 CMM Mailchimp: Updating contacts in CiviCRM

Is there any way to figure out why it is hanging?

My groups are setup like this:

OrgX - main group setup with 'Sync membership of this group with membership of a Mailchimp List' -- SubOrgA - child group setup with 'No integration'
-- List1 - child group setup with 'Sync membership of with a Mailchimp interest grouping'

There are several SubOrgs and Lists underneath the main OrgX group. I would have liked to only sync the child lists with Mailchimp because there are some child lists I don't want in Mailchimp, but it appears syncing the parent group (OrgX) is required. Is that correct?

Thank you for you help, Malachi

Kajakaran commented 8 years ago

@cmmadmin

Yes you need parent group syncing.

Please see below set-up

CiviCRM Mailchimp

Parent 1 - List 1 child 1 - Interesting Grouping 1 -> group 1 child 2 - Interesting Grouping 1 -> group 2 child 3 - Interesting Grouping 2 -> group 1

In Mailchimp, We have subscribers in groups, it is part of Mailchimp List. That is subscribers won't be there in groups if there are not in Mailchimp List.

The same logic applies here in group set-up in CiviCRM. Contacts in child groups should be in parent as well.

cmmadmin commented 8 years ago

Thanks for the reply. I removed the intermediate groups in CiviCRM so now my setup is:

OrgX - main group setup with 'Sync membership of this group with membership of a Mailchimp List' | -- List1 - child group setup with 'Sync membership of with a Mailchimp interest grouping'

I enabled debugging in Mailings > Mailchimp Settings. Then, I tried 'Sync Mailchimp Contacts To Civi' again. This time I saw several emails processed with 'updateParamsExactMatch' and 'getGroupsToSync' after about 30 minutes it stopped with the following being the last output to the log. Should I try to 'Sync Mailchimp Contacts to Civi' instead?

Apr 22 11:06:26  [info] $Start-CRM_Mailchimp_Utils updateParamsExactMatch $params = Array
(
    [FNAME] => Foo
    [LNAME] => Bar
    [EMAIL] => foobar1@gmail.com
    [status] => Array
        (
            [Added] => 0
            [Updated] => 0
        )
)
Apr 22 11:06:26  [info] $Start-CRM_Mailchimp_Utils updateParamsExactMatch $contactids = Array
(
    [0] => 153112
)
Apr 22 11:06:26  [info] $End-CRM_Mailchimp_Utils updateParamsExactMatch $contactParams = Array
(
    [version] => 3
    [first_name] => Foo
    [last_name] => Bar
    [email] => foobar1@gmail.com
    [id] => 153112
)
Apr 22 11:06:27  [info] $End-CRM_Mailchimp_Utils getGroupsToSync $groups = Array
(
)
Apr 22 11:06:27  [info] $End-CRM_Mailchimp_Utils updateContactDetails $contactID = 153112
Apr 22 11:06:27  [info] $Start-CRM_Mailchimp_Utils updateContactDetails $params = Array
(
    [FNAME] =>
    [LNAME] =>
    [EMAIL] => foobar2@efc-canada.com
)
Apr 22 11:06:27  [info] $Start-CRM_Mailchimp_Utils updateContactDetails $delay =
Apr 22 11:06:27  [info] $Start-CRM_Mailchimp_Utils getContactFromEmail $email = foobar2@efc-canada.com
Apr 22 11:06:27  [info] $Start-CRM_Mailchimp_Utils getContactFromEmail $primary = 1
Apr 22 11:06:27  [info] $End-CRM_Mailchimp_Utils getContactFromEmail $contactids = Array
(
    [0] => 149821
)
Apr 22 11:06:27  [info] $Start-CRM_Mailchimp_Utils updateParamsExactMatch $params = Array
(
    [FNAME] =>
    [LNAME] =>
    [EMAIL] => foobar2@efc-canada.com
    [status] => Array
        (
            [Added] => 0
            [Updated] => 0
        )
)
Apr 22 11:06:27  [info] $Start-CRM_Mailchimp_Utils updateParamsExactMatch $contactids = Array
(
    [0] => 149821
)
Apr 22 11:06:27  [info] $End-CRM_Mailchimp_Utils updateParamsExactMatch $contactParams = Array
(
    [version] => 3
    [email] => foobar2@efc-canada.com
    [id] => 149821
)
Apr 22 11:06:27  [info] $End-CRM_Mailchimp_Utils getGroupsToSync $groups = Array
(
)
Apr 22 11:09:20  [info] $End-CRM_Mailchimp_Utils getGroupsToSync $groups = Array
(
)
cmmadmin commented 8 years ago

I went ahead and exported all my contacts in Mailchimp and imported them into the new groups in CiviCRM. I did this for the parent list (with all 9,630 contacts) and the child groups (i.e., interest groupings). Then, I ran 'Sync Civi Contacts to Mailchimp' which also hung at about 80%. I ran it twice and let it run overnight.

If I am certain the groups are in sync (at this point in time), then is there any reason to run 'Sync Civi Contacts To Mailchimp' or 'Sync Mailchimp Contacts To Civi'? Or, can I just skip that step and rely on the web hooks to keep them up to date moving forward?

Kajakaran commented 8 years ago

@cmmadmin

Initially, depending on your requirement, you can run either 'Sync Mailchimp Contacts To Civi' or 'Sync Civi Contacts to Mailchimp'.

Example - if you have no contacts in civi group and have subscribers in mailchimp then you can run 'Sync Mailchimp Contacts To Civi'.

if you have no subscribers in mailchimp and have contacts in civicrm then you can run 'Sync Civi Contacts to Mailchimp'.

After this you can set-up cron for 'Mailchimp Sync' job which is run automatically every day which will pull(Mailchimp -> Civi) first and then sync(Civi -> Mailchimp)

Also by setting up webhook will make sure any subscribe/un subscribe in mailchimp will instantly impact on Civi by adding/removing from group.

deepak-srivastava commented 7 years ago

We think latest v2.x has fixed this. Please re-open if the issue still exist. Thanks.