New Topic
This topic can no longer be replied to because it has been locked.

Add custom entry to send within the Merge Fields
Gravatar
Joined: 2014-08-07
Posts: 2617
By default the extension can send any Customer attribute, the ones from Magento and the ones created by custom extensions. If you want to send information that is not specifically a customer attribute, you need to create a custom entry. (i.e Date of last purchase)

To do this you will need some PHP and Magento knowledge.
First you need to go to the configuration of the extension at the Customer Fields Mapping section.
Then you have to click on Add new custom data entry in the column of the right and a pop up will show up.

There you will add the new attribute, Merge Field Name is the name to display on the dropdown of the column of the right, Merge Field Type is the type of the Merge Field in case you want to create it remotely with the Create Merge Fields button below and Merge Field Tag is the string that will be used when programming the data associated to this new custom field.

Edit: Since version 1.1.6 there is an event dispatched where the logic to retrieve the data should be placed.

Finally you need to create an event observer in the config.xml file located at app/code/community/Ebizmarts/MailChimp/etc/
It is important it is inside the global node.
Around line 288 you should see something similar to this:
<catalog_product_save_before> <observers> <mailchimp_save_before_product> <type>model</type> <class>mailchimp/observer</class> <method>productSaveBefore</method> </mailchimp_save_before_product> </observers> </catalog_product_save_before>

Below that you need to the following:
<mailchimp_merge_field_send_before> <observers> <[your_custom_observer_name]> <type>model</type> <class>[custom_modulename/observer</class> <method>[custom_method_name]</method> </[your_custom_observer_name]> </observers> </mailchimp_merge_field_send_before>

Please note that everything between brackets is not the actual text, you need to adapt it to your situation, the brackets must not be in the final solution, just a under-score separated text.

You need to create your own module in order to keep the functionality whenever you update MailChimp For Magento.

If you do not want to do all this the observer can be created in our own observer.
To do this place the following in the config.xml file:

<mailchimp_merge_field_send_before> <observers> <[your_custom_observer_name]> <type>model</type> <class>mailchimp/observer</class> <method>[custom_method_name]</method> </[your_custom_observer_name]> </observers> </mailchimp_merge_field_send_before>

You can put whatever you want in stead of the text inside the brackets , it won't affect the functionality.

If you used the last case then you need to go to app/code/community/Ebizmarts/MailChimp/Model/Observer.php and add a new function at the bottom.

Public function [custom_method_name]($observer) { $event = $observer->getEvent(); $emailAddress = $event->getSubscriberEmail(); $mergeFieldTag = $event->getMergeFieldTag(); $mergeFieldValue = $event->getMergeFieldValue(); //Be careful since all the merge fields will go through this observer, do not affect the default ones. if ($mergeFieldTag == [your_custom_attribute_tag]) { //Add logic here } $event->setMergeFieldValue([your_custom_attribute_value]);

After this the custom value should be sent associated to the tag you created in MailChimp.

Regards,
Santiago.

NEWSLETTER

Subscribe to our newsletter to receive emails and useful news articles