Creating an attribute and defining allowable values
As a catalog manager, you can create attributes and define values to them.
DisplayType
so that it can be displayed on the store website. The
display type includes LED, QLED, Mini LED, and OLED. Since DisplayType
is not an
application-provided item definition, the catalog manager can create a new attribute by using the
Attribute API.- Item Attribute Name =
DisplayType
- Item Attribute Group Path = /TV/DisplayDefinition
- Allowed values = LED, QLED, MiniLed, OLED
POST https://api.watsoncommerce.ibm.com/catalog/{tenantid}/v1/attributes
{
"attributes": [
{
"itemAttributeName": "DisplayType",
"itemAttributeGroupPath": "/TV/DisplayDefinition",
"dataType": "String",
"multipleValuesAllowed": false,
"isValueMandatory": true,
"allowedValues": ["QLED","LED", "MiniLed", "OLED"],
"description": "QLED Television Display Type"
}
]
}
multipleValuesAllowed
- Defines whether an item attribute can support multiple values.isValueMandatory
- Determines whether an attribute value can be left blank.
For the flat panel television example, multipleValueAllowed
is set to false as a
TV can be only of one display type, and the value is mandatory to ensure the website of a store
always has a value for the display type. When allowed values are provided, the catalog service
validates that an item attribute value matches at least one of the allowedValues
.
Suppose a user sets the value of QLED01
, the application results in a failure as
the attribute definition allows only QLED
as an option.
Lastly, itemAttributeGroupPath
is notable mention, although it is free from
text. It is recommended that for a directory structure uses the forward slash (/
) notation. In the example,
/TV/DisplayDefinition, indicate that the DisplayType
belongs
to the parent TV and DisplayDefinition
as a subtype. By using this paradigm, you
can organize an attribute in a strategical manner. If you have Sterling Order Management System
Software, use the forward slash (/
) notation to minimize the integration
complexity.