Commerce Server 2007 Code Samples - Catalog System and Basic Catalog Search

I did some qualitative analysis of the referrals of my blog, and found that a majority of the search terms are for Commerce Server Code Samples or for Commerce Server API usage samples.Though some very good code samples are available at the Microsoft Commerce Server Product Unit blog, it is extremely difficult to get hold of them as they have been filed either under Webcasts as attachments or in the context of a different article.

I will try to get hold of some genuine code samples that are spread across the MSDN blogs including the blogs of key developers who worked on the product. I will be posting more such items as and when I find them (or I find time to find them). I'll also be including code snippets of some real-life searches using the Commerce Server 2007 APIs that am working on.

A terrific set of code samples for the Commerce Server 2007 Catalog System has been uploaded in the e-commerce blog by Vinayak Tadas who was a developer in the team that developed the product. the original post is here. I have attached the same code samples in this entry and can be downloaded for reference (without any implicit or explicit warranty or support from either me or Microsoft Corp. whatsoever : By downloading you accept all the risks involved without any liability on the part of Microsoft Corp. or myself.)

The attached CatalogWebCast_CodeSamples.zip file contains samples for:

Runtime Commerce Server APIs (those that are used to retrieve info for use in a e-commerce website)

  • ProductCatalog: Getting products from a catalog along with its child products
  • CatalogContext.GetCatalogs: Getting a set of catalogs from the current context
  • CatalogContext.GetCategory: Getting the details of a category including child categories
  • CatalogContext.GetProduct: Getting the details of a product and product family including the variants
  • CatalogSearch: Searching the catalog with the basic properties specified

Design-time Commerce Server APIs (those that are used to create products, catalogs etc)

  • CreateProperty: Creating a CatalogProperty using the CreateProperty method of the CatalogContext
  • CatalogEnumerationProperty: Creating a CatalogEnumerationProperty using the overloaded CreateProperty method
  • CreateDefinition:
    • Creating a CatalogDefinition using the CreateDefinition of CatalogContext
    • Creating a ProductDefinition using the CreateDefinition of CatalogContext
  • .... and lots more...

Get the attachment: