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 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 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, 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 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 typeDescriptionSupports localizationExample use caseNotes
    AttributeBooleanTypeStores boolean values (true/false).NoProduct availability (in stock/out of stock), featured product-
    AttributeTextTypeStores plain text values.NoProduct SKU, brand name, short description-
    AttributeLocalizableTextTypeStores localized text values for multiple languages.YesProduct name in English, Spanish, and French; detailed description in multiple languages-
    AttributeEnumTypeStores a single value from a predefined list of plain text options.NoProduct size (S, M, L), product categoryUse AttributeSetType for allowing multiple selections.
    AttributeLocalizedEnumTypeStores a single value from a predefined list of localized text options.YesProduct color (Red, Blue, Green) in different languagesUse AttributeSetType for allowing multiple selections.
    AttributeNumberTypeStores numerical values.NoProduct weight, product dimensions, shoe size-
    AttributeMoneyTypeStores monetary values with currency information.NoProduct price, discount amount-
    AttributeDateTypeStores date values.NoProduct release date, expiry date-
    AttributeTimeTypeStores time values.NoEvent start time, delivery window-
    AttributeDateTimeTypeStores combined date and time values.NoOrder creation date and time-
    AttributeReferenceTypeStores references to other resources within Composable Commerce.NoLinking a product to a specific category, associating a product with a particular brand or manufacturer.-
    AttributeSetTypeStores a set of values of a specific Attribute Type.Depends on the element typeSelecting multiple colors for a product, choosing multiple sizesCan be nested to create complex data structures.
    AttributeNestedType BETAStores 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.

    Test your knowledge