how to create a new product in Commerce Server 2009 in C#-Collection of common programming errors

Add the reference of CommerceServer.Catalog assembly and the use the below code. You should create an instance of the catalog context object using Service agent or Site agent.

Example using Site agent{CatalogSiteAgent catalogSiteAgent = new CatalogSiteAgent();catalogSiteAgent.SiteName = “Your Web site”;CatalogContext catalogContext = CatalogContext.Create(catalogSiteAgent);

}

Create product using catalog context

{BaseCatalog baseCatalog = (BaseCatalog)catalogContext.GetCatalog(your catalog name);Product product = baseCatalog.CreateProduct(your definition Name, productId);product.DisplayName = “Display name of the product”;product.ListPrice = 25.00;product.Save();return product;

}