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?
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;