How to sort products on a SystemFieldTypeConstants.TextOption value?
For example, in the SearchQueryBuilder would I like to change SearchQueryConstants.Popular to be sorting on the TextOption.Item with value “MestSalda”.
SearchQueryBuilder:
public void ApplyCategorySorting()
{
switch (_searchQuery.SortBy)
{
...
case SearchQueryConstants.Popular:
_request.Sortings.Add(new Sorting(FilteringConstants.GetMostSoldTagName(_requestModelAccessor.RequestModel.WebsiteModel.SystemId), SortDirection.Descending, SortingFieldType.Float));
break;
...
}
}
TextOption definition in ProductsFieldDefinitionSetup:
new FieldDefinition<ProductArea>(ProductFieldNameConstants.ItemExtraLabels, SystemFieldTypeConstants.TextOption)
{
CanBeGridColumn = false,
CanBeGridFilter = false,
Option = new TextOption
{
MultiSelect = true,
Items = new List<TextOption.Item>
{
new TextOption.Item
{
Value = "MestSalda",
Name = new Dictionary<string, string> { { "en-US", "Most sold" }, { "sv-SE", "Mest sålda" } }
},
new TextOption.Item
{
Value = "Kampanj",
Name = new Dictionary<string, string> { { "en-US", "Promotional" }, { "sv-SE", "Kampanj" } }
},
new TextOption.Item
{
Value = "BraMiljoval",
Name = new Dictionary<string, string> { { "en-US", "Good Eco-choice" }, { "sv-SE", "Bra miljöval" } }
},
}
}
},
Litium version: 7.2.3