function mailchimp_lists_get_subscribers in Mailchimp 8
Same name and namespace in other branches
- 7.5 modules/mailchimp_lists/mailchimp_lists.module \mailchimp_lists_get_subscribers()
- 7.3 modules/mailchimp_lists/mailchimp_lists.module \mailchimp_lists_get_subscribers()
- 7.4 modules/mailchimp_lists/mailchimp_lists.module \mailchimp_lists_get_subscribers()
- 2.x modules/mailchimp_lists/mailchimp_lists.module \mailchimp_lists_get_subscribers()
Batch processor for pulling in subscriber information for a list/audience.
1 string reference to 'mailchimp_lists_get_subscribers'
- mailchimp_lists_update_member_merge_values in modules/
mailchimp_lists/ mailchimp_lists.module - Triggers an update of all merge field values for appropriate entities.
File
- modules/
mailchimp_lists/ mailchimp_lists.module, line 392 - Mailchimp lists/audiences module.
Code
function mailchimp_lists_get_subscribers(FieldConfig $field, &$context) {
if (!isset($context['sandbox']['progress'])) {
$context['results']['subscribers'] = [];
$context['sandbox']['progress'] = 0;
}
$limit = 100;
$options = [
'offset' => $context['sandbox']['progress'] / $limit,
'count' => $limit,
];
$mc_list_id = $field
->getFieldStorageDefinition()
->getSetting('mc_list_id');
$matches = mailchimp_get_members($mc_list_id, 'subscribed', $options);
if ($matches) {
if (!isset($context['sandbox']['max'])) {
$context['sandbox']['max'] = $matches->total_items;
}
foreach ($matches->members as $result) {
$context['results']['subscribers'][strtolower($result->email_address)] = $result;
$context['sandbox']['progress']++;
}
$context['message'] = t('Check subscription status for contact %count of %total.', [
'%count' => $context['sandbox']['progress'],
'%total' => $context['sandbox']['max'],
]);
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
}
}