在 Kentico 10 中删除 AutomaticContactMerger class 的解决方法
Workaround for removed AutomaticContactMerger class in Kentico 10
我们已经升级了一个使用 Kentico 10 中的 AutomaticContactMerger class, up to Kentico 10 which no longer contains that class. The API Changes reference guide notes the class as being removed 的 Kentico 8.2 网站,但不建议使用其合并功能的替代方法或解决方法。
TL;DR 摘要
我们正在寻找一种方法来移植我们的联系人管理自定义合并逻辑,并在 Kentico 运行其默认合并逻辑时将其集成到 Kentico 10 中,就像我们在 Kentico 8 中所做的那样 post(下)。
在侵入 Kentico 10 API 之前——无论它看起来像什么——我正在寻找建议或解决方法以最好地使用 Kentico 10 APIs 来实现相同的结果: 注册将参与 Kentico 10 默认合并过程的自定义合并。
自定义合并逻辑
具体来说,我们的项目覆盖了 Kentico 8 AutomaticContactMerger
class 并提供自定义逻辑,如以下 C#.NET Kentico 8 代码片段所示。 (此代码已被简化和净化以传达基本场景。)
理解这段代码:
- 我们在 Kentico Contact class 上有一个名为
EXTERNAL_REFERENCE_VALUE
的自定义字段(字符串字段),它的值最终从外部系统填充但不是立即(可能为空),所以我们围绕此字段值的存在(它是否为空)以及它包含的值来确定我们的一些逻辑,以便自定义我们 select 覆盖默认合并逻辑的联系人。
- 提到 K8 和 K10 的源代码注释分别表示 Kentico 版本 8 和 10。
/* 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;
}
我们在上述 Kentico 8 代码片段中用于提供自定义合并行为的 classes 和方法的简短列表是这些:
CMS.OnlineMarketing
命名空间 -
AutomaticContactMerger
class - 从 Kentico 10 中删除,包括:
.MergeWithinSite(..)
虚方法被覆盖
.GetWhereCondition(..)
虚方法被覆盖
.ContactIsMergedByColumn(..)
实例方法被调用
ContactHelper
class - 但是存在于 Kentico 10 中:
.Merge(..)
使用了静态方法,Kentico 10 中不再存在
使用 Kentico 8 注册自定义合并逻辑
此外,我们通过以下标准方式通过提供商向 Kentico 8 注册我们自己的 CustomContactMerger
class。 Kentico 8 方法 CMS.OnlineMarketing.ContactInfoProvider.AddAutomaticContactMerger(..)
在 Kentico 10 中也不再存在,因此我们将需要一种方法来在 Kentico 10 中注册自定义合并。Kentico 8 将此方法描述为
/// 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 发行说明关于核心产品中联系人管理的更改,因为它与 CMS Desk 功能相关:
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
Kentico 版本 10 中的联系人发生了重大变化。我会在这里参考发行说明:https://docs.kentico.com/k10/release-notes-kentico-10#Releasenotes-Kentico10-Contactmanagement
查看以
开头的段落
By default, the system only merges contacts automatically, ...
就建议而言,我会尝试一个完全没有自定义的测试站点,以了解联系人和活动的工作原理,新的开箱即用设置可能适合您。
或者,如果您分享您的合并逻辑,我们可能会提供更多帮助。
我们已经升级了一个使用 Kentico 10 中的 AutomaticContactMerger class, up to Kentico 10 which no longer contains that class. The API Changes reference guide notes the class as being removed 的 Kentico 8.2 网站,但不建议使用其合并功能的替代方法或解决方法。
TL;DR 摘要
我们正在寻找一种方法来移植我们的联系人管理自定义合并逻辑,并在 Kentico 运行其默认合并逻辑时将其集成到 Kentico 10 中,就像我们在 Kentico 8 中所做的那样 post(下)。
在侵入 Kentico 10 API 之前——无论它看起来像什么——我正在寻找建议或解决方法以最好地使用 Kentico 10 APIs 来实现相同的结果: 注册将参与 Kentico 10 默认合并过程的自定义合并。
自定义合并逻辑
具体来说,我们的项目覆盖了 Kentico 8 AutomaticContactMerger
class 并提供自定义逻辑,如以下 C#.NET Kentico 8 代码片段所示。 (此代码已被简化和净化以传达基本场景。)
理解这段代码:
- 我们在 Kentico Contact class 上有一个名为
EXTERNAL_REFERENCE_VALUE
的自定义字段(字符串字段),它的值最终从外部系统填充但不是立即(可能为空),所以我们围绕此字段值的存在(它是否为空)以及它包含的值来确定我们的一些逻辑,以便自定义我们 select 覆盖默认合并逻辑的联系人。 - 提到 K8 和 K10 的源代码注释分别表示 Kentico 版本 8 和 10。
/* 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;
}
我们在上述 Kentico 8 代码片段中用于提供自定义合并行为的 classes 和方法的简短列表是这些:
CMS.OnlineMarketing
命名空间 -
AutomaticContactMerger
class - 从 Kentico 10 中删除,包括:.MergeWithinSite(..)
虚方法被覆盖.GetWhereCondition(..)
虚方法被覆盖.ContactIsMergedByColumn(..)
实例方法被调用
ContactHelper
class - 但是存在于 Kentico 10 中:.Merge(..)
使用了静态方法,Kentico 10 中不再存在
使用 Kentico 8 注册自定义合并逻辑
此外,我们通过以下标准方式通过提供商向 Kentico 8 注册我们自己的 CustomContactMerger
class。 Kentico 8 方法 CMS.OnlineMarketing.ContactInfoProvider.AddAutomaticContactMerger(..)
在 Kentico 10 中也不再存在,因此我们将需要一种方法来在 Kentico 10 中注册自定义合并。Kentico 8 将此方法描述为
/// 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 发行说明关于核心产品中联系人管理的更改,因为它与 CMS Desk 功能相关:
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
Kentico 版本 10 中的联系人发生了重大变化。我会在这里参考发行说明:https://docs.kentico.com/k10/release-notes-kentico-10#Releasenotes-Kentico10-Contactmanagement
查看以
开头的段落By default, the system only merges contacts automatically, ...
就建议而言,我会尝试一个完全没有自定义的测试站点,以了解联系人和活动的工作原理,新的开箱即用设置可能适合您。
或者,如果您分享您的合并逻辑,我们可能会提供更多帮助。