Paging in Commerce Server.

We have a requirement to set up variants for a product, but display each variant as a product.When we use Paging for our listing, the paging is paged in context of products and not in variants , so we display more number of products ( as each product has many variants) than the page size, worst page 2 and on are totally messed up.

Is there a way that I can page on products * variant than just on products in commerce server

Code Used:

CategoryConfiguration categoryConfiguration = new CategoryConfiguration();
categoryConfiguration.LoadChildProducts = true;

CatalogSearchOptions catalogSearchOptions = new CatalogSearchOptions();
catalogSearchOptions.ClassTypes = CatalogClassTypes.ProductClass | CatalogClassTypes.ProductFamilyClass| CatalogClassTypes.ProductFamilyVariantClass ;

catalogSearchOptions.SetPaging(pageNumber, pageSize);

categoryConfiguration.ChildProducts.SearchOptions = catalogSearchOptions;

ProductCollection pc = CommerceContext.Current.CatalogSystem.GetCatalog(catalogName).GetCategory(categoryName, categoryConfiguration).ChildProducts;
totalRecords = pc.TotalRecords;

[1158 byte] By [msdate] at [2008-2-2]
# 1

This might not be possible with a single call.

You can get the number of products * variants by making another call and Passing CategoryClass.Variants and use that number to control paging.

VinayakTadas-MSFT at 2007-9-4 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 2

Using this Code, we get paging for products and variants,

CatalogContext catalogContext = CommerceContext.Current.CatalogSystem;
CatalogSearchOptions catalogSearchOptions = new CatalogSearchOptions();
catalogSearchOptions.ClassTypes = CatalogClassTypes.ProductVariantClass;
catalogSearchOptions.PropertiesToReturn = "productID,VariantID";
catalogSearchOptions.SetPaging(1, 2);

CatalogSearch catalogSearch = catalogContext.GetCatalogSearch();
catalogSearch.SearchOptions = catalogSearchOptions;
catalogSearch.CatalogNames = "CatalogName";
catalogSearch.CategoryName = "CategoryName";

CatalogItemsDataSet Ds = catalogSearch.Search(out totalRecords);

How-ever, If we have a requirement for paging to get paging in context of product in some cases and product,variant combinations in some cases, is there a solution for this?

For Eg: A Category can have books and clothing items, but when the category is displayed books need to be displayed once per variant and clothes as per product, can we implement this kind of paging in a clean way, say like a union operator for the above search and staying away from using a sql clause going against commerce server tables?

msdate at 2007-9-4 > top of Msdn Tech,Commerce Server,Commerce Server 2007...