Page 1 of 1
ProductList Sort Function
Posted: Mon Dec 13, 2010 9:43 am
by jsmits
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);
Re: ProductList Sort Function
Posted: Tue Dec 14, 2010 8:34 am
by mazhar
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");
Re: ProductList Sort Function
Posted: Tue Dec 14, 2010 8:45 am
by jsmits
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);