Related products.

Currently for performance reasons I do a CatalogSearch to get a list of all of the products (and variants) in the catalog. This returns a DataSet which for constructing the variant relationships is just fine. The problem is that I want to be able to get the related products. The only way that I know of doing that is to convert the DataRow describing the product to a CS Product object as follows:

Microsoft.CommerceServer.Catalog.Product product = catalogContext.GetProduct("MyCatalog", currentProductId);

Then using this Product I can use the property RelatedProducts to get a DataSet containing the products that are related to this Product. This works but it is really slow. I have a feeling that the main bottleneck is the conversion (GetProduct) toMicrosoft.CommerceServer.Catalog.Product.Is there another way that I can get the related products using the product id? I get the product id from the search, which returns a

Microsoft.CommerceServer.Catalog.CatalogItemsDataSetif that is helpful.

Thank you.

Kevin

[1618 byte] By [KevinBurton] at [2008-1-7]
# 1

I'm sure that you're right about that being the bottleneck. Most likely, you don't need all of the data coming back from GetProduct, but you need more than you are getting from the search. My solution to this has been to add the extra fields that you need to the search options object you are executing the search with, and avoiding the conversion to a Product object altogether.

Ideally, you have a business-layer product object that wraps around the Commerce Server Product object. This wrapper can be created with a Commerce Server Product, or some subset of data instead. As it is used around the site, it will attempt to just work off of the subset of data it has. Only if some data is requested that is not in that subset, does it goes to the trouble of getting the actual Commerce Server Product object and incurring those costs.

When you perform your search, you create these product wrappers from the search results, feeding them the subset of the product data that you have and a null commerce server Product object. Then you use those wrappers throughout your site instead of the Commerce Server product object.

Of course, that's just one solution (lazy loading). I'm sure there are others, and the best fit will depend on your situation.

JaredHodges at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 2

Sorry to be ignorant but I am not sure what fields to add to the Commerce Server Product object. I only want the "related products". I am not sure what fields I can add so that it will make it less costly to find the related products. Maybe an example?

Thank you.

Kevin

KevinBurton at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 3

My apologies, Kevin, I misunderstood your initial post! I will try to find some time later today to look into what you were really asking, but hopefully someone else will come along with a solution before then.

JaredHodges at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 4
You can try using the ProductConfiguration class with the GetProduct method to load RelatedProducts initially. You can find more information onthe ProductConfiguration class at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdkmref/html/T_Microsoft_CommerceServer_Catalog_ProductConfiguration.asp

and more information about the GetProduct method with ProductConfiguration as an input parameter at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdkmref/html/M_Microsoft_CommerceServer_Catalog_CatalogContext_GetProduct_2_e14b5ac9.asp

A sample can be found at: http://msdn2.microsoft.com/en-us/library/aa545800.aspx

Thanks

Sudha

SudhaRaghavan-MSFT at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 5
Sudha Raghavan - MSFT wrote:
You can try using the ProductConfiguration class with the GetProduct method to load RelatedProducts initially. You can find more information onthe ProductConfiguration class at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdkmref/html/T_Microsoft_CommerceServer_Catalog_ProductConfiguration.asp

and more information about the GetProduct method with ProductConfiguration as an input parameter at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdkmref/html/M_Microsoft_CommerceServer_Catalog_CatalogContext_GetProduct_2_e14b5ac9.asp

A sample can be found at: http://msdn2.microsoft.com/en-us/library/aa545800.aspx

Thanks

Sudha

This makes a marginal imporvement but when I try to get the relationships for a whole catalog it still takes a long time. (12,000 relationship items in 870 seconds about 14 items(relationships)/second). Basically the small speed improvement is that I can get the variants from the Product class which is also the source for the related products. In other words i can use the Product class for both but I am guessing but it still takes a long time to construct the Product class.

Thank you.

Kevin

KevinBurton at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...