Microsoft Developer Network >
Forums Home
>
Commerce Server Forums
>
Commerce Server 2009
>
Variant Query Sort Property Bug
Variant Query Sort Property Bug
- In addition to the where clause having no affect on a related variant query the SortProperties don't appear to work either. I have tried the following code to find the result does not sort the ProductColor properties like I had expected.
var queryProducts = new CommerceQuery<CommerceEntity>("Product"); queryProducts.SearchCriteria.Model.Properties["CatalogId"] = "Adventure Works Catalog"; queryProducts.SearchCriteria.Model.Properties["Id"] = "AW029-03"; queryProducts.SearchCriteria.Model.Properties[Product.PropertyName.ParentId] = "Shirts"; var queryVariants = new CommerceQueryRelatedItem<Variant>("Variants"); queryVariants.Model.Properties.Add("Id"); queryVariants.Model.Properties.Add("ProductColor"); queryVariants.SearchCriteria.SortProperties = new System.Collections.Generic.List<CommerceSortProperty>(); queryVariants.SearchCriteria.SortProperties.Add(new CommerceSortProperty("Variant", "ProductColor", SortDirection.Ascending)); queryProducts.RelatedOperations.Add(queryVariants);It should be noted that using the following does return the product color variants sorted as expected.
var query = new CommerceQuery<CatalogEntity, CommerceCatalogFullTextSearchBuilder>(); query.SearchCriteria.Catalogs.Add("Adventure Works Catalog"); query.SearchCriteria.CategoriesClause = "[CategoryName] = 'Shirts'"; query.SearchCriteria.WhereClause = "[ProductId] = 'AW029-03' and [ProductColor] != 'Green'"; query.SearchCriteria.SortProperties = new System.Collections.Generic.List<CommerceSortProperty>(); query.SearchCriteria.SortProperties.Add(new CommerceSortProperty("Variant", "ProductColor", SortDirection.Ascending)); CommerceResponse response = commerceProxy.ProcessRequest(commerceContext, query.ToRequest()); var queryResponse = response.OperationResponses[0] as CommerceQueryOperationResponse;What am I missing?
All Replies
- Hi Johnny,
If you outline the logic of the method you are trying to write, I can provided you with an example?
Thanks,
Lewis
Follow Me on Twitter: @LewisBenge Or check out my blog: http://www.geekswithblogs.com/pointtoshare/ - Get all variants for product
AW029-03 from the Adventure works Catalog and sort by product color ascending.
Like I said in the original post I know that querying by
CommerceCatalogFullTextSearchBuilder
works. Really just looking for why the SortProperties on a Variant related query have no affect.

