Inventory Attributes
Inventory attributes may be defined for the following entities: Product
, ProductVariant
, and ProductInstance
.
For a specific Product
/ProductVariant
/ProductInstance
, it is possible to set or edit a specific set of product attributes as specified in the product template.
A product template is a collection of product attributes. A product category may define the following properties:
ProductTemplate
VariantTemplate
InstanceTemplate
These properties dictate which attributes are used for products, variants, or instances. Each of these properties can be overridden at the product level.
Get Product Attributes
Method: POST
URL: {host_url}/api/inventory/productAttribute/GetProductAttributes
Minimal Request
{
}
This method returns a collection of all defined product attributes. Each product attribute has a Kind
, which is an enum of type ProductAttributeKind
, with the following options:
Unknown = 0,
String = 1,
StringOptions = 2,
Int = 3,
IntOptions = 4,
Decimal = 5,
DecimalOptions = 6,
Memo = 7,
Url = 8,
Actor = 9,
Date = 10,
Catalog = 11
Resolve Product Attribute Values
Product
, ProductVariant
, and ProductInstance
entities have an AttributeValues
collection. These are usually included optionally in responses. For example:
- Product instance attributes are included by default when returned by the
GetProductInstancePage
method. - Product attributes on a product page have a more complex inclusion mechanism explained in the GetProductPage documentation.
Each element in the AttributeValues
collection is of type ProductAttributeValueBase
, containing:
- A
ProductAttribute
field with minimal information (SystemName
,Kind
, andDisplayName
). - A
ProductAttributeId
field that can be used to resolve full attribute data from theGetProductAttributes
method. - A set of properties (
StringValue
,IntValue
, etc.) that store the attribute value.
Resolving Attribute Values
The following pseudo-code outlines how to determine which property holds the attribute value:
switch (productAttributeValue.Kind) {
case ProductAttributeKind.String:
case ProductAttributeKind.StringOptions:
return productAttributeValue.StringValue;
case ProductAttributeKind.Memo:
return productAttributeValue.MemoValue;
case ProductAttributeKind.Url:
return productAttributeValue.UrlValue;
case ProductAttributeKind.Int:
case ProductAttributeKind.IntOptions:
return productAttributeValue.IntValue;
case ProductAttributeKind.Decimal:
case ProductAttributeKind.DecimalOptions:
return productAttributeValue.DecimalValue;
case ProductAttributeKind.Date:
return productAttributeValue.DateValue;
case ProductAttributeKind.Actor: // Actor ID will be returned
case ProductAttributeKind.Catalog: // Catalog value ID will be returned
return productAttributeValue.EntityIdValue;
}
Resolve Product Attribute Catalog Value
If a product attribute has kind Catalog
, its value is stored in the EntityIdValue
field of ProductAttributeValue
.
- This value corresponds to a CatalogValueItemId.
- To display it, the catalog value must be retrieved and displayed using its
Code
andValue
. - To resolve the catalog system name, retrieve the ProductAttribute by ID.
- A
Catalog
-type ProductAttribute has a populatedCatalogPreferences
property, which containsCatalogSystemName
. This can be used to fetch catalog values.
Get Catalog Values by System Name
Method: POST
URL: {host_url}/api/catalogs/catalogValue/GetCatalogValues
Minimal Request
{
"catalogSystemName": "catalogSystemName"
}
This method returns a collection of catalog values for the specified catalog. The desired catalog value can be found using its ID.
Resolve Product Attribute Actor Value
If a product attribute has kind Actor
, its value is stored in the EntityIdValue
field of ProductAttributeValue
.
- This value corresponds to an
ActorId
. - The minimal way to display actor data by ID is to retrieve the actor text.
Get Actor Texts
Method: POST
URL: {host_url}/api/actors/actor/GetActorTexts
Minimal Request
{
"ids": { "value": [actorIdsArray] }
}
This method returns a collection of values of type EntityDescriptor
, where each entry has a DisplayValue
property that can be used as the product attribute value.