Sitecore DEF + SXA — Part 2: Resolving SXA local data source item

Jack Spektor
2 min readJun 26, 2022

Hello friends.

This is the continuation on my series of SXA+DEF code snippets.

You can see my previous post from the series here:

Sitecore DEF + SXA — Part 1: Handling duplicate items when resolving item | by Jack Spektor | Jun, 2022 | Medium

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:

Sitecore.DEF.SXA/ResolvePageDatasourceProcessor.cs at main · JackTheHack/Sitecore.DEF.SXA (github.com)

Here in this custom DEF step we are doing 3 things:

  1. 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.

See ya!

--

--

Jack Spektor

Sitecore MVP 2018–2020, Sitecore Developer in AKQA, traveler and lover of life.