Attribute types

Define product data structure with Attribute types.

Ask about this Page
Copy for LLM
View as Markdown

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, different types of product information require different data containers. That's where Attribute types come in. They define the specific kind of data an 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 Blue
  • Size: an enum with options like S, M, L, and XL
  • Material: a text string
  • Neckline: 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 Grey
  • Length: a number
  • Fit: an enum with options like Slim, Regular, and Relaxed
  • Washing 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 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, the name might be tshirt_color, while the label would be Color.
  • isRequired: determines whether the Attribute is mandatory for a Product Variant. If set to true, 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, if Color and Size Attributes are set as CombinationUnique, 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.

For the complete list of Attribute types with their properties, constraints, and supported values, see AttributeType in the API reference.

When choosing an Attribute type, consider the following factors:

  • Data format: match the type to the data you need to store (for example, use AttributeNumberType for numeric values like weight, and AttributeEnumType for a fixed set of options like sizes).
  • Localization needs: if you need to store translated values, use AttributeLocalizableTextType or AttributeLocalizedEnumType.
  • Multiple values: to allow multiple selections (for example, multiple colors), use AttributeSetType wrapping the desired element type.
  • Structured data: for tabular or nested data structures, use AttributeNestedType BETA to reference another Product Type. This type is limited to five levels of nesting within an AttributeSetType. For more details, see Nested Attribute type.

Test your knowledge