Reputation: 28869
We've upgraded a Kentico 8.2 website that uses the AutomaticContactMerger class, up to Kentico 10 which no longer contains that class. The API Changes reference guide notes the class as being removed in Kentico 10 but does not suggest alternatives or workarounds to using its merging features.
We are looking for a way to port our Contact Management custom merge logic and integrate it into Kentico 10 at the point Kentico runs its default merge logic, just as we did in Kentico 8 as shown in this post (below).
Before hacking into the Kentico 10 API -- whatever that might look like -- I'm looking for recommendations or workarounds to best use the Kentico 10 APIs to achieve the same outcomes: to register custom mergers that will participate in the Kentico 10 default merge process.
Specifically, our project overrides the Kentico 8 AutomaticContactMerger
class and provides custom logic as shown in the following C#.NET Kentico 8 code snippet. (This code has been simplified and sanitised to convey the basic scenario.)
To understand this code:
EXTERNAL_REFERENCE_VALUE
(string field) that ultimately has its value populated from an external system but not immediately (might be empty), so we key some of our logic around this field value's presence (is it empty or not) and of course the value it contains, in order to customize which Contacts we select to override the default merge logic./* In Kentico 8 we derive from the CMS.OnlineMarketing.AutomaticContactMerger class
to provide custom merge logic
based on custom contact fields and rules ... */
public class CUSTOM_ContactMerger : AutomaticContactMerger /* K10 Removed ACM class */ {
// ==============================================
// In K8 OVERRIDE the default Merge with our custom logic.
protected override ContactInfo MergeWithinSite(ContactInfo contact, List<ContactInfo> contacts, string siteName) {
if (!base.ContactIsMergedByColumn(FieldNames.Contact.EXTERNAL_REFERENCE_VALUE)) {
/* Custom logic determines which contacts will be merged */
var contacts = CUSTOM_GetAllTheContactsIWantToMergeBasedOnCustomRules(..);
/* Find or make a master contact - more custom rules wrapped up */
ContactInfo masterContact = CUSTOM_GetMyPreferredMasterContactOrMakeANewOne();
/* Use Kentico's ContactHelper class to merge all our picked Contacts into the master contact.*/
ContactHelper.Merge(masterContact, contacts, null, null); // however the .Merge methods are gone in K10
return masterContact; // custom selection
// ==============================================
// in K8 OVERRIDE the Where Condition for when merge should be ignored (for example).
protected override string GetWhereCondition(ContactInfo contact) {
if (CUSTOM_ShouldIgnoreMerge(contact)) {
return string.Empty;
}
return base.GetWhereCondition(contact) ?? string.Empty;
}
A short list of classes and methods we use in the above Kentico 8 code snippet to provide custom merge behaviour, and which no longer exist in the Kentico 10 API are these:
CMS.OnlineMarketing
namespace -
AutomaticContactMerger
class - removed from Kentico 10 including:
.MergeWithinSite(..)
virtual method is overridden.GetWhereCondition(..)
virtual method is overridden.ContactIsMergedByColumn(..)
instance method is calledContactHelper
class - exists in Kentico 10 however:
.Merge(..)
static method is used, no longer exists in Kentico 10Additionally, we register our own CustomContactMerger
class with Kentico 8 through a provider in the following standard way. The Kentico 8 method CMS.OnlineMarketing.ContactInfoProvider.AddAutomaticContactMerger(..)
also no longer exists in Kentico 10, so we will need a way to register custom mergers in Kentico 10. Kentico 8 describes this method as
/// Registers automatic contact merger that gets ran when method SetContactInfo is called.
[assembly: RegisterCustomProvider(typeof(CustomContactInfoProvider))]
public partial class CustomContactInfoProvider : ContactInfoProvider
static CustomContactInfoProvider()
{
var myCustomMerger = new CustomContactMerger(..);
// Note: we do NOT use Kentico's own email settings, because they will be picked up
// by Kentico's private method and give email higher priority (than our own merger logic)
var emailMerger = new CustomContactMerger("ContactEmail", CustomContactMerger.SETTING_MERGE_BY_EMAIL);
var mergers = new List<CustomContactMerger>() { merger, emailMerger };
foreach (var m in mergers)
{
// Kentico 8 registration point. Kentico 10 does not have this method call.
base.AddAutomaticContactMerger(m);
}
Kentico 10 Release Notes about changes to contact management in the core product, as it relates to CMS Desk features:
By default, the system only merges contacts automatically, which caused the following changes:
- It is no longer possible to merge accounts and split the merged accounts in the Contact management application.
- It is no longer possible to manually merge contacts and split the merged contacts in the Contact management application.
- It is no longer possible to clone the merged accounts in the Clone account dialog and the merged contacts in the Clone contact dialog.
- The Automatic merging of contacts setting category with the following settings was removed from Settings -> On-line marketing -> Contact management -> Global data & merging:
- Merge contacts for identical E-commerce customers; Merge contacts for identical Email campaign subscribers; Merge contacts with identical email addresses and When a visitor has more contacts, use.
~ https://docs.kentico.com/k10/release-notes-kentico-10#Releasenotes-Kentico10-Contactmanagement
Upvotes: 0
Views: 139
Reputation: 1529
There was a major change to contacts in version 10 of Kentico. I would refer to the release notes here: https://docs.kentico.com/k10/release-notes-kentico-10#Releasenotes-Kentico10-Contactmanagement
Check out the paragraph that starts with
By default, the system only merges contacts automatically, ...
As far as recommendations go, I would try a test site with no customization at all to understand how contacts and activities work, the new out of the box setup may just work for you.
Alternately, if you share your merge logic we might be able to help more.
Upvotes: 0