ProductList Sort Function

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
jsmits
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Wed Sep 30, 2009 11:57 am

ProductList Sort Function

Post by jsmits » Mon Dec 13, 2010 9:43 am

Does CommerceBuilder have a built in function to sort a list of products? Below is how I retrieve the list, I'd like to be able to sort this list by ModelNumber or Sku.

Code: Select all

List<Product> productList = ProductDataSource.NarrowSearch(string.Empty, _CategoryId, 0, 0, 0, 0, 0, string.Empty);

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: ProductList Sort Function

Post by mazhar » Tue Dec 14, 2010 8:34 am

Try

Code: Select all

List<Product> productList = ProductDataSource.NarrowSearch(string.Empty, _CategoryId, 0, 0, 0, 0, 0, "P.ModelNumber");
or

Code: Select all

List<Product> productList = ProductDataSource.NarrowSearch(string.Empty, _CategoryId, 0, 0, 0, 0, 0, "ModelNumber");

User avatar
jsmits
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Wed Sep 30, 2009 11:57 am

Re: ProductList Sort Function

Post by jsmits » Tue Dec 14, 2010 8:45 am

Hi Mazhar, thanks as always for the response.

What I settled on was the following which works quite nicely:

Code: Select all

List<Product> productList = ProductDataSource.NarrowSearch(string.Empty, _CategoryId, 0, 0, 0, 0, 0, string.Empty);

ProductCollection productCollection = new ProductCollection();
productCollection.AddRange(productList);

productCollection.Sort("ModelNumber", GenericComparer.SortDirection.ASC);

Post Reply