Try our conversational search powered by Generative AI!

Sorting by built-in properties

Vote:
 

Is there a way to sort entries by their built-in properties like price, name, created. Tried using some of the names of these but can't get it to work. The only thing that I got working was creating another custm filed with the same data and sort on that. That works for text properties but not so well on prices since the price can be changed and then the custom field is not updated.

I create the SearchSort like this:

public virtual SearchSort CreateSearchSort(string sortName, string sortOrder)
        {
            var searchSort = CatalogEntrySearchCriteria.DefaultSortOrder;

            if (string.IsNullOrEmpty(sortName)) return searchSort;

            var isDescending = (sortOrder == "desc");

            return new SearchSort(sortName, isDescending);
        }

    

And then Im building a criteria with that and performs a regular search like this:

var entries = _searchFilterHelper.SearchEntries(criteria, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo), false, new TimeSpan());

    

What name should I use for the built in properties if it is possible to use them in sorting?

#74217
Aug 22, 2013 14:25
Vote:
 

After some good input from EPiServer Support I finally foudn out how to see what values that can be used for sorting:

Either use Luke to open the search index and view the documents or

run the following code to get the documents from Commerce searchmanager

 SearchManager m = new SearchManager(Mediachase.Commerce.Core.AppContext.Current.ApplicationName);
            var res = m.Search(criteria);
            var doc = res.Documents[0];

#75556
Sep 30, 2013 8:50
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.