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
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
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
type: specifies the Type of the Attribute, for example, text, enum, and number.name: the unique identifier for the Attribute within your 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, thenamemight betshirt_color, while thelabelwould 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, ifColorandSizeAttributes 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 Projection 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
A diverse range of Attribute types is available to accommodate various Product data needs. Attribute types range from simple types (boolean, text, number, date, and time) to more complex types (enum, localized enum, money, reference, set, and nested). Some Attribute types support localization, letting you store different values for the same Attribute in different languages. Localization support is crucial for creating a multilingual shopping experience.
When choosing an Attribute type, consider the following factors:
- Data format: match the type to the data you need to store (for example, use
AttributeNumberTypefor numeric values like weight, andAttributeEnumTypefor a fixed set of options like sizes). - Localization needs: if you need to store translated values, use
AttributeLocalizableTextTypeorAttributeLocalizedEnumType. - Multiple values: to allow multiple selections (for example, multiple colors), use
AttributeSetTypewrapping the desired element type. - Structured data: for tabular or nested data structures, use
AttributeNestedTypeBETA to reference another Product Type. This type is limited to five levels of nesting within anAttributeSetType. For more details, see Nested Attribute type.