KeyField
A KeyField works much similar to a Field. They are for example output just as fields. Marking a mapping KeyField tells EC that this field holds a unique identifier for the entity.
KeyField | ||
What can be output | Supports | Supported Entities |
a Features a Attributes r Literals | r Multi value features r Localizable features r Output Kind Parameters | a Site a Category a Product a Variant |
Sample Mappings | ||
  | ||
Sample output | ||
 <Product id="636" ecommerceproduct="983ST">
 <Fields>
    <Field name="Item No">983ST</Field>
  </Fields>
  …
</Product> |
Table 1: Summary of output kind KeyField.
If you do not have any feature on an entity that holds a unique value you can choose to map the Perfion ID on the Item by mapping from the attribute .id. Perfion guarantees that this holds a unique id for all items in Perfion. Usually on products and variants, however, you will have a feature containing the unique Item Number for the product/variant, but this is maybe rarer in the case for categories and sites. Here the attribute .id could be an easy alternative to invent and populate a feature for holding some unique id.
It is not mandatory to define a KeyField on entities, but recommended. In case you use Related Products, Related Categories or if support for variants is needed, a KeyField is necessary.
NOTE: EC does not support multiple key fields for the same entity (sometimes called compound keys).