# Attribute types 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](/api/projects/productTypes.md#attributetype) come in. They define the specific kind of data an [Attribute](/merchant-center/product-types.md) can hold, ensuring data consistency and accuracy across your product catalog. Think of them as the building blocks of Product information. [Product Types](/api/projects/productTypes.md) 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: ```mermaid flowchart TB subgraph subGraph1["Product Type: Jeans"] AT_JeansColor("Attribute Type: Color (enum: Blue, Black, Grey)") AT_JeansSize("Attribute Type: Length (number)") AT_Fit("Attribute Type: Fit (enum: Slim, Regular, Relaxed)") AT_Wash("Attribute Type: Washing Instructions (text)") end subgraph s2["Product: Blue Slim Fit Jeans"] n2["Product values"] end subgraph subGraph2["Product Type: T-Shirt"] AT_Color("Attribute Type: Color (enum: Red, Green, Blue)") AT_Size("Attribute Type: Size (enum: S, M, L, XL)") AT_Material("Attribute Type: Material (text)") AT_Neckline("Attribute Type: Neckline (enum: Crew, V-Neck)") end subgraph s1["Product: Red Crew Neck T-Shirt"] n1["Product values"] end subGraph1 --> s2 subGraph2 --> s1 ``` ## Attribute Definitions Within each Product Type, you define [Attribute Definitions](/api/projects/productTypes.md#attributedefinition) 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. To use the same Attribute name across multiple Product Types for search, filters, or facets, set `isSearchable` to `true` for all of them. If the `isSearchable` values are different, the Attribute isn't available for search, filters, or facets. ## 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](/urn?urn=ctp%3Aapi%3Atype%3AAttributeType) 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` to reference another Product Type. This type is limited to five levels of nesting within an `AttributeSetType`. For more details, see [Nested Attribute type](/learning-model-your-product-catalog/attribute-types-and-attribute-groups/nested-attribute-type.md). ## Related pages - [Area overview page with navigation](/learning-model-your-product-catalog.md) - [Previous page: Overview](/learning-model-your-product-catalog/attribute-types-and-attribute-groups/overview.md) - [Next page: Nested Attribute type](/learning-model-your-product-catalog/attribute-types-and-attribute-groups/nested-attribute-type.md)