Extension attributes in the data model
Extension attributes are a category of attributes that represents a combination of attributes such as item-type attributes and other attributes.
- Item-type attributes, or
- Item-category attributes, or
- Item-characteristics attributes
Item-type attributes
Item-type attributes are attributes that are applicable only to items of the same type. For example, collar size and sleeve size are attributes specific to shirts and waist and length attributes are specific to pants.- Option 1
- You can attach a secondary spec by running a post-save script on certain item types. If you choose this approach, you can model item types and subtypes as a hierarchical structure and attach item-category specs at the type and subtype level.
- Option 2
- Using a secondary hierarchy that you can create the categories that depict the item types. The item-type specific attributes can be attached as item category specs. When you set up the items, you can categorize the items in this hierarchy to obtain the additional set of attributes. This approach also provides a different way to navigate the item assortment in the catalog. If you choose this option, you can attach the secondary spec directly without needing to first define a separate hierarchy.
When you define item types, do not model every variation as a different item type. For example an MP3 player with audio compared to an MP3 player with audio and video. These do not need to be separate item types, but rather modeled as one item type MP3 and define a set of attributes that allow you to indicate whether it is audio, video or both. You can also decrease the granularity by classifying the item into audio item type and having an attribute to indicate whether it is an MP3 player. The more granular item types are more flexible but the maintenance cost of secondary specs is high.
Item-category attributes
The item-category attributes are used for extending an item's attribute set.Item-category attributes are tied to an item's classification. For example, if an item is classified under Perishable goods, then an attribute for a best before date is added. With item-category attributes, you can dynamically extend an item's attribute set and avoid having one large Primary spec in all items.
The data modeling of item-category attributes is similar to item-type attributes. You can model item-category attributes with a secondary hierarchy because the classification hierarchy exists. Each category within hierarchy has its own item-category spec, which gets assigned to the item upon classification.
Item-characteristic attributes
Item-characteristic attributes are based on a particular item characteristic and are used to extend an item's attribute set. These attributes are similar to item-type and item-category attributes.For example, if an item is marked as sellable then certain attributes such as sales channel might need to be added.
You must refrain from modelling Item-characteristic attributes because it requires a granular form of defining dynamic attributes. Instead, you can assign such attributes to all items and move the requirements as part of data validations. For example, if an item is marked as sell-able then make sure that at least one sales channel is selected or return a validation error. In this case, the sales channel attribute is visible to all the items regardless of whether they are sellable or not but needs only to be populated for sell-able items.