Bucket Folder Path Resolution Allows Inheritance

SXA allows you to configure bucket folder path rules on your multisite Settings item, for example /sitecore/Content/(tenant)/(site)/Settings in the "Rules for Resolving the Bucket Folder Path" field.

We had a list of rules - one for each of the bucket folders that we're using to store data being imported via Data Exchange Framework pipeline batches. This grew slowly but steadily over time, with our process being:

  • Create a new data template and folder template to represent the data, configuring the standard values as required.
  • Create an instance of the folder to hold the data
  • Build the pipeline to import/update the data
  • Add a rule to this Settings item to configure the bucketing for the folder template

This was based on the initial assumption that we might have different bucketing requirements, plus looking at the default "where the item bucket is based on the <template> template" rule suggested that it was looking for an exact match on the selected template.

Looking at the implementatio of that rule, the Sitecore item definition is located in the /sitecore/system/Settings/Rules/Definitions/Elements/Bucketing, and is named Bucket Item Template.

The underlying type is Sitecore.Buckets.Rules.Bucketing.Conditions.WhenBucketTemplateIs (in Sitecore.Buckets) and looking at the actual implementation of that we found that it checks not just the folder template itself, but also checks against the list of base templates.

This meant we could simplify by creating a new "Bucketing Base Folder" template, inherit that on to all of our type-specific folder templates, and simplify the bucket folder rule down to just "where the item bucket is based on the <Bucketing Base Fodler> template" to have the rule applied consistently.