Multiple Mailchimp Accounts
Optionally, configure the service container to handle multiple Mailchimp accounts. This works the same way as configuring multiple newsletter lists via Mailchimp provider handler services (see Configuration for an example definition).
In addition to the standard constructor arguments of the Mailchimp provider handler class, set up a dedicated export service that holds a Mailchimp client configured with the alternative API key.
An example configuration looks like this:
appbundle.cmf.mailchimp.client:
class: DrewM\MailChimp
arguments:
- 'my-example-api-key'
appbundle.cmf.mailchimp.export-service:
class: CustomerManagementFrameworkBundle\Newsletter\ProviderHandler\Mailchimp\MailChimpExportService
arguments:
- '@appbundle.cmf.mailchimp.client'
appbundle.cmf.mailchimp.handler.list1:
class: CustomerManagementFrameworkBundle\Newsletter\ProviderHandler\Mailchimp
autowire: true
arguments:
# Shortcut of the handler/list for internal use
$shortcut: list1
# List ID within Mailchimp
$listId: ls938393f
# Mapping of Pimcore status field => Mailchimp status
$statusMapping:
manuallySubscribed: subscribed
singleOptIn: subscribed
doubleOptIn: subscribed
unsubscribed: unsubscribed
pending: pending
# Reverse mapping of Mailchimp status => Pimcore status field
$reverseStatusMapping:
subscribed: doubleOptIn
unsubscribed: unsubscribed
pending: pending
# Mapping of Pimcore data object attributes => Mailchimp merge fields
$mergeFieldMapping:
firstname: FNAME
lastname: LNAME
street: STREET
birthDate: BIRTHDATE
# Special data transformer for the birthDate field.
# This ensures that the correct data format will be used.
$fieldTransformers:
birthDate: '@appbundle.cmf.mailchimp.birthdate-transformer'
$exportService: '@appbundle.cmf.mailchimp.export-service'
tags: [cmf.newsletter_provider_handler]