To place the Products in CatalogManager we need a BaseCatalog. Once we have a catalog schema defined for e-commerce site then we can add actual data in form of BaseCatalogs, VirtualCatalogs, Categories, Products etc. To Create a BaseCatalog we need to provide the values to some of the parameters by calling the CreateBaseCatalog() method using the Catalog Manager. We can also categorize products as per some criteria and place the products of same categories in a Category associating them.
Here we can go through how we can create a new BaseCatalog using Commerce Server API and Adding Categories and Products to the BaseCatalog.
STEP – I(Create Catalog Context in agent mode):
[CatalogContext can be created in two ways in agent mode as well as in local mode using SiteName]
CatalogServiceAgent catalogServiceAgent = new CatalogServiceAgent("http://localhost/CatalogWebService/CatalogWebService.asmx"); CatalogContext catalogContext = CatalogContext.Create(catalogServiceAgent);
STEP – II(Create the BaseCatalog):
BaseCatalog catalog = context.CreateBaseCatalog("MyCatalog", "ProductID", "Color", "en-US", "en-US");
Parameters used :
1. CatalogName : Name of the catalog to be created 2. ProductId : Name of the Property which should be used asproduct identification property 3. VariantId : Name of the property which should be used as variant identification property in base catalog. 4. DefaultLanguage : Default language for the catalog.(CultureCode)
reportingLanguage : Reporting Language for the Catalog. It is used while exporting data to warehouse.
STEP -III(Create the Category within the BaseCatalog):
catalog.CreateCategory(categoryDefinitionName, categoryName);
Parameters used :
1. CategoryDefinitionName : Name of the category definition present in the catalog schema
2. CategoryName : Name of the new category to be created.
STEP – IV(Create the Product by passing the appropreate parameter values):
CommerceProduct product = catalog.CreateProduct(catalogName, "00021", 200, parentCategoryName);
Parameters used : 1. DefinitionName : Name of the ProductDefinition present in the catalog schema 2. ProductId : Identifier for the Product(value should be non-empty, not null, max size 256 characters) 3. ListPrice : ListPrice of the product in catalog.
4. ParentCategoryName : Name of the parent category already present in catalog to which the product will be associated
STEP – V(Set the values for the product properties):
product["SKU"] = "00021"; product["DisplayName"] = "00021"; product["Color"] = "BrightWhite"; product["Brand"] = "ClassicCotton"; product["Colorfamily"] = "Whites"; product["GeneralWeight"] = "5.8 lbs"; product["Size"] = 23;
STEP -VI(Save the Product):
product.Save();