How to create a CatalogProperty and add enum values to it in CommerceServer using API

The Catalog schema consists of metadata like definitions for Products, properties and categories stored in the site’s product catalog database.

Commerce Server Catalog System provides a set of APIs to manage catalog schema for your e-commerce site. By using this we can create definitions of property, category and product. We can also update the properties.

Here we can learn how to create an Enumeration Property and add the enum values to it.

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/MindfireCatalogWebService/
CatalogWebService.asmx");

CatalogContext catalogContext = CatalogContext.Create(catalogServiceAgent);

 STEP -II(Create COLOR property of data type Enumeration):

CatalogEnumerationProperty catalogProperty = (CatalogEnumerationProperty)catalogContext.CreateProperty("Color", CatalogDataType.Enumeration, 5);

The parameters used for CreateProperty method are as follows:
1. PropertyName :– A string value of maximum length 100 character containing name for the property.
2. PropertyDataType :- A value of type Microsoft.CommerceServer.Catalog.CatalogDataType enumeration represents datat type for property.
3. Size :- The size for a string data type.

STEP – III(Add enumeration values to newly created property):

catalogProperty.AddEnumerationPropertyValue("Red");
catalogProperty.AddEnumerationPropertyValue("Blue");
catalogProperty.AddEnumerationPropertyValue("Green");
catalogProperty.AddEnumerationPropertyValue("Black");
catalogProperty.AddEnumerationPropertyValue("White");

 STEP – IV(Save change to Catalog System):

catalogProperty.Save();
150 150 Burnignorance | Where Minds Meet And Sparks Fly!