Sitecore DEF + SXA — Part 2: Resolving SXA local data source item
This is the continuation on my series of SXA+DEF code snippets.
You can see my previous post from the series here:
Today we are going to talk on how to create SXA local data sources through DEF.
Today most of Sitecore websites are based either on SXA or JSS as it saves time for development effort.
Therefore migrating data from other systems should also take into account using SXA.
What if for example we want to create a new local SXA data source like this one?
We can’t simply use ResolveItem step that comes OOTB as it wouldn’t use Data folder that exists.
Here how we can solve this problem though with custom code:
Here in this custom DEF step we are doing 3 things:
- We are creating new data folder if it doesn’t exist yet
2. We override the default ResolveItem pipeline logic to use the data folder as a parent item instead
Now our DEF pipeline would be able to create SXA datasources under Data folder.
P.S: In the next article I’m going to continue on SXA+DEF series and would cover on how to add new rendering to the item with custom DEF pipeline.