0

I'm using Sitecore 9.2 and SXA 1.9, I wonder how SXA Pagelist component works in terms of querying items, does it fetch items from Solr as SXA SearchResults one.

I tried decompiling its dll, but couldn't totally understand how it does it, and I there are no requests is triggered to the Solr when using it.

If they use the same approach, when to use Pagelist over SearchResults component.

2

It seems that PageList in this SXA version isn't using solr queries like search results component, if you take a look in Sitecore.XA.Feature.PageContent.Repositories.PageListRepository it makes a call to this.GetItems(this.Rendering, this.Rendering.Parameters["SourceType"], this.IsEdit).

Depending on the Source Type set on the component (Children, Sibling, Items with the same template) this method is doing a SelectItems query

if (!str.StartsWith("query:", StringComparison.OrdinalIgnoreCase))
    return this.GetDatasourceItem(str, dataSourceItem);
string query = ServiceLocator.ServiceProvider.GetService<ITokenResolver>().Resolve(str, dataSourceItem);
Item[] items = dataSourceItem.Axes.SelectItems(query) ?? Array.Empty<Item>();
return (IEnumerable<Item>) this.EvaluateRules(queryItem, items);

You can find this in Sitecore.XA.Foundation.RenderingVariants.Repositories.ListRepository namespace. You can take a look at the sitecore documentation which details some cases where you should use Page List component.

In the latest SXA version it was changed so that it is using search queries aswell:

return str.IsSitecoreQuery() ? this.GetSitecoreQueryItems(dataSourceItem, queryItem, str) : this.GetContentSearchQueryItems(dataSourceItem, queryItem, str); 
1
2

Pagelist and SearchResult might be used to show the same results (both coming from the index) but actually they work quite different.

First difference is the way they work together with other components: the SearchResults are designed to work well with the other search components like the searchbox, the facet filters and so on. The Pagelist is not designed this way. They do both support a pagination.

Another important difference is how (and where) the data is fetched. A pagelist will fetch (and show) the data in the components backend - the searchresults will trigger a javascript call that fetches the results and shows them in the browser.

Setting the data is a bit different between both components but both can show data coming from an index query.

So in short to answer your when to use what question: if you want a component that can be combined with filters and/or uses a js call to fetch the results you should go for the searchresults. Otherwise the pagelist will do.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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