Attribute types
Define product data structure with Attribute types.
After completing this page, you should be able to:
- Identify the appropriate Attribute type for a given product characteristic, considering factors such as data type, localization needs, and validation rules.
Imagine you're building a house. You wouldn't use the same materials for the walls, windows, and roof, would you? Similarly, in Composable Commerce, different types of product information require different data containers. That's where Attribute types come in. They define the specific kind of data a Product Attribute can hold, ensuring data consistency and accuracy across your product catalog. Think of them as the building blocks of Product information.
Product Types define a set of Attribute types relevant to that specific category of products. In other words, Product Types are like blueprints for your products. For instance, a T-Shirt
Product Type might include Attribute types for:
Color
: an enum with options like Red, Green, and BlueSize
: an enum with options like S, M, L, and XLMaterial
: a text stringNeckline
: an enum with options like Crew and V-Neck
On the other hand, a Jeans
Product Type might have Attribute types for:
Color
: an enum with a different set of options like Blue, Black, and GreyLength
: a numberFit
: an enum with options like Slim, Regular, and RelaxedWashing Instructions
: a text string
This structured approach ensures that you only collect relevant information for each product. You wouldn't ask for the Neckline
of a pair of jeans, would you? By defining appropriate Attribute types for each Product Type, you prevent irrelevant or nonsensical data from being entered, maintaining data integrity and simplifying product management.
Let's visualize this as a flowchart:
Attribute Definitions
Within each Product Type, you define Attribute Definitions that provide metadata about each Attribute. These definitions include:
type
: specifies the Type of the Attribute, for example, text, enum, and number.name
: the unique identifier for the Attribute within your Composable Commerce Project. This name is used programmatically to reference the Attribute.label
: a human-readable label for the Attribute, displayed in the Merchant Center. For example, thename
might betshirt_color
, while thelabel
would beColor
.isRequired
: determines whether the Attribute is mandatory for a Product Variant. If set totrue
, you cannot create a Product Variant without providing a value for this Attribute.attributeConstraint
: specifies how an Attribute (or a set of Attributes) should be validated across all Product Variants within a Product:Unique
: Attribute values must be different for each Product Variant.CombinationUnique
: Attributes must have a unique combination for each Product Variant. For example, ifColor
andSize
Attributes are set asCombinationUnique
, two Product Variants cannot have the same color and size combination (for example, "Red, Large" can only appear once per Product Variant).SameForAll
: Attribute value should be the same in all Product Variants.None
: No constraints are applied to the Attribute.
inputTip
: provides guidance to content managers when setting product details in the Merchant Center. You can use this field to explain the Attribute's purpose or provide specific instructions for entering data.inputHint
: provides visual representation directives for specific Attribute types. For example, you can specify that an Attribute of type text should be displayed as a multi-line text area.isSearchable
: determines if the Attribute's values are searchable in the Product Projections Search API or in the Product Search API. Make Attributes searchable if you want your customers to find Products based on their Attribute values.
The spectrum of Attribute types
Composable Commerce offers a diverse range of Attribute types to accommodate various product data needs.
Attribute type | Description | Supports localization | Example use case | Notes |
---|---|---|---|---|
AttributeBooleanType | Stores boolean values (true/false). | No | Product availability (in stock/out of stock), featured product | - |
AttributeTextType | Stores plain text values. | No | Product SKU, brand name, short description | - |
AttributeLocalizableTextType | Stores localized text values for multiple languages. | Yes | Product name in English, Spanish, and French; detailed description in multiple languages | - |
AttributeEnumType | Stores a single value from a predefined list of plain text options. | No | Product size (S, M, L), product category | Use AttributeSetType for allowing multiple selections. |
AttributeLocalizedEnumType | Stores a single value from a predefined list of localized text options. | Yes | Product color (Red, Blue, Green) in different languages | Use AttributeSetType for allowing multiple selections. |
AttributeNumberType | Stores numerical values. | No | Product weight, product dimensions, shoe size | - |
AttributeMoneyType | Stores monetary values with currency information. | No | Product price, discount amount | - |
AttributeDateType | Stores date values. | No | Product release date, expiry date | - |
AttributeTimeType | Stores time values. | No | Event start time, delivery window | - |
AttributeDateTimeType | Stores combined date and time values. | No | Order creation date and time | - |
AttributeReferenceType | Stores references to other resources within Composable Commerce. | No | Linking a product to a specific category, associating a product with a particular brand or manufacturer. | - |
AttributeSetType | Stores a set of values of a specific Attribute Type. | Depends on the element type | Selecting multiple colors for a product, choosing multiple sizes | Can be nested to create complex data structures. |
AttributeNestedType BETA | Stores nested Attributes based on an existing Product Type. | Depends on the nested Attributes. | Storing nutritional information for food products, defining technical specifications for electronics. | Limited to five levels of nesting within AttributeSetType . |
Supports localization indicates if you can store different values for the same Attribute in different languages. This is crucial for creating a multilingual shopping experience.