1

We're running Sitecore 9.3.2 with Commerce. We had a favorites implementation, which used a custom model in xDb. This all worked fine, but due to some changes requested by the client, we decided to create a completely custom approach that uses SQL tables.

I have now been tasked with removing the custom xDb pieces from the code. Which in and of itself is fairly straight forwards. However, if I remove the custom model and facet from the xDb, will xDb continue to serialize the json ok (Ie ignoring the custom facet that has been removed from the code), or do I need to run something to update all the facet data in the shard databases?

Any thoughts would be much appreciated.

N.B. I should also point out that we have at least 1.5 million customer records in the database.

2
  • do you want to remove custom facets data from shard databases for all the contacts? Apr 1, 2022 at 12:16
  • 1
    I’m removing the models and I need to know if that will impact existing users. I don’t want to have to update 1.5 million users unless it’s absolutely necessary.
    – jwsadler
    Apr 1, 2022 at 15:12

2 Answers 2

0

To answer your question, if you remove custom facets model DLL and model JSON from all roles, it will not remove custom facets data for existing customers in shard DBs. For the new customers, these facets will not be applicable. So technically, this will not impact anything for existing or new customers.

But these redundant facets values are increasing the shard DB size and will impact indexer performance. To prevent these situations, you can consider removing custom facets data for all existing contacts in XDB. Unfortunately, I am not aware of anything to remove complete Facets from the contact in XDB, so just explaining how you can remove the attributes from those custom facets:

  • First of all, in your custom facet model class remove all the attributes and build the DLL.
        [Serializable]
        [FacetKey(DefaultFacetKey)]
        public class CustomFacetClass: Facet
        {
            public const string DefaultFacetKey = "CustomFacetKey";
        }
  • Serialize the collection model in which you defined your custom facet model and deploy the generated JSON file to all required roles. This json will not have any attributes just class, namespace or facet names.
  • Now create a utility to update/remove the redundant facets data in XDB.
  • To do that, gets contacts from xDB in batches of 200 and then just set the empty facet values to custom facet.
   // write logic to get all contacts from XDB
   // iterate through the contact, set the facet and submit back contacts to xdb using batching process
    foreach(var contact in allXDBContacts)
    {
    var CustomFacet = contact.GetFacet<CustomFacetKey>(CustomFacetKey.DefaultFacetKey);
    if(CustomFacet !=null)
    {
    client.SetFacet(contact, CustomFacet);
    }                       
    }
  • After running this for all xDB contacts, check the existing contacts in shard DBs, they will still have the custom facets but no facets data for them.
0
  1. Remove custom facets model DLL and model JSON

  2. Run the below query on both Shard0 and Shard1

    begin tran
    
    Update [xdb_collection].[ContactFacets] set facetData=''  where facetkey='CustomFacetKey'
    
    Commit
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.