自定义联系人构面未保存

时间:2019-05-06 09:04:05

标签: asp.net sitecore8

我正在使用Sitecore 8.2。而且,我尝试将自定义方面应用到我的联系信息中。我在这里遵循指南:https://doc.sitecore.com/developers/82/sitecore-experience-platform/en/the-merge-contacts-rules.html

但是以某种方式我创建的自定义构面没有被索引到solr中。我已经尝试过模仿sitecore的遗留代码和配置。但它仍然无法正常工作。

我尝试使用Sitecore的非自定义旧构面进行比较,它可以正常工作。

我想解决这个问题吗?

ISubscription.cs

public interface ISubscription: IElement, IValidatable, IFacet
    {
        string SubscriptionIds
        {
            get;
            set;
        }
    }

Subscription.cs

[Serializable]
    internal class Subscription: Facet, ISubscription, IFacet, IElement, IValidatable
    {
        private const string SUBSCRIPTION_IDS = "SubscriptionIds";

        public Subscription()
        {
            base.EnsureAttribute<string>(SUBSCRIPTION_IDS);
        }
        public string SubscriptionIds
        {
            get
            {
                return base.GetAttribute<string>(SUBSCRIPTION_IDS);
            }

            set
            {
                base.SetAttribute<string>(SUBSCRIPTION_IDS, value);
            }
        }
    }

Sitecore.Analytics.Model.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <model>

      <elements>
        ....
        <element interface="MyProject.Custom.Contact.Entities.ISubscription, MyProject.Custom" implementation="MyProject.Custom.Contact.Generated.Subscription, MyProject.Custom"/>
      </elements>

      <entities>
        <contact>
          <factory type="Sitecore.Analytics.Data.ContactFactory, Sitecore.Analytics" singleInstance="true" />
          <template type="Sitecore.Analytics.Data.ContactTemplateFactory, Sitecore.Analytics" singleInstance="true" />
          <facets>
            ....
            <facet name="Subscription" contract="MyProject.Custom.Contact.Entities.ISubscription, MyProject.Custom" />
          </facets>
        </contact>
      </entities>
    </model>

  </sitecore>
</configuration>

调试代码

//This is indexed
var personal = newContact.GetFacet<Sitecore.Analytics.Model.Entities.IContactPersonalInfo>("Personal");
personal.FirstName = "Jane";
personal.Surname = "Janeth";

//This is indexed
var phone = newContact.GetFacet<Sitecore.Analytics.Model.Entities.IContactAddresses>("Addresses");
phone.Entries.Create("Preferred").StreetLine1 = "St. Berkeley";

//This is not indexed
var subscription = newContact.GetFacet<ISubscription>("Subscription");
subscription.SubscriptionIds = "subscription-to-newsletter";

0 个答案:

没有答案