SortingOptions for the ProductList widget
1. Is it possible to sort by a custom field that I've added to my products ? (e.g. MostPopular )
2. Is there a list of possible values to put in the Advanced Settings->SortOder list ?
PriceAsc:PriceAscendingOptionText, PriceDesc:PriceDescendingOptionText,NameAsc:NameAscendingOptionText, NameDesc:NameDescendingOptionText, CreatedDate:CreatedDateOptionText
Thanks in advance for any insight,
Tim
Hi Tim,
Here is more information on your question:
For the sorting options, you can add any default fields there, those are basically coma separated key value pairs. The keys(NameAsc etc.) can be names of any of the default fields(any fields that toggle under the default section in your product type).
The ones you see there basically are short form of the following :
internal const string CreatedDate = "PublicationDate DESC";internal const string PriceAsc = "Price ASC";internal const string PriceDesc = "Price DESC";internal const string NameAsc = "Title ASC";internal const string NameDesc = "Title DESC";using System;using System.Linq;using Telerik.Sitefinity.Data;using Telerik.Sitefinity.Ecommerce.Catalog.Model;using Telerik.Sitefinity.Modules.Ecommerce.Catalog.Interfaces;namespace SitefinityWebApp.Widgets public class CustomSortFilter : IProductExpressionFilter public Tuple<IQueryable<Product>, int?> SortAndFilterProducts(IQueryable<Product> products, int skip, int? take, string filterExpression, string sortExpression) //this is the default implementation, you can add your logic that checks for the field(s) //you need and does the filtering here. int? totalCount = 0; var filteredProducts = DataProviderBase.SetExpressions( products, filterExpression, sortExpression, skip, take, ref totalCount); return new Tuple<IQueryable<Product>, int?>(filteredProducts, totalCount); protected void Application_Start(object sender, EventArgs e) Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += Bootstrapper_Initialized; protected void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args) if (args.CommandName == "Bootstrapped") ObjectFactory.Container.RegisterType(typeof(IProductExpressionFilter), typeof(CustomSortFilter)); How would I implement this into the backend eCommerce products for sorting a custom field called StartDate. I can't figure out where to reference this code inorder to use it.
Thank you.
Hello Anthony,
For the time being it is not possible to sort the ecommerce products in the backend by custom field. We have logged this as a feature request in our feedback portal on the following link:
http://feedback.telerik.com/Project/153/Feedback/Details/152369-ability-to-sort-products-in-the-backend-grid-by-custom-field
You can subscribe to receive notifications for the feature request including new comments, votes, status changes by clicking on the "Follow this item" link. If you would like to unsubscribe, you can unfollow the item by removing "Following this item”.
You can also vote to increase the popularity of the feature request.
I also created a KB article related to this:
http://www.sitefinity.com/developer-network/knowledge-base/details/sorting-products-in-the-backend-grid-by-custom-field
Regards,
Sabrie Nedzhip
Telerik