Attributes and Types Overview
An attribute is a reusable field that can be assigned to a product or a variant, similar to fields in a CMS.
Here is an overview of all possible attribute types:
Name | Description | Example |
---|---|---|
Dropdown | List of predefined choices; rendered as a single-select dropdown. | Store a color of a variant with predefined choices: orange, black, blue, etc. |
Multiselect | List of predefined choices; rendered as a multi-select dropdown. | Add multiple tags to a product or a page. |
File | Allows to store a file as an attribute value; rendered as a file input. | Store a product manual as a PDF file; store a hero image for a page. |
Reference | Values are references to other entities such as products, variants or pages. | Render a list of related products on a product page. |
Numeric | Values are numbers; optionally, a unit can be provided to represent measures and dimensions. | Dimensions of a product represented with three numeric attributes: length, width, and depth. |
Rich text | Value is stored as rich-text content; rendered as a rich-text editor. | Additional content blocks for a page or product. |
Boolean | Allows storing boolean values. | Yes/no properties, e.g., "Product is fair trade certified: yes/no". |
Date | Allows storing date values. | Store release date of a product. |
Date time | Allows storing date-time values. | Store release date with the time of a product. |
Product and Content Types​
A type is a collection of attributes that make up the shape of data in a product or a content block.
Reusable attributes​
Each attribute configuration is reusable across different product types, which is convenient when managing them across multiple products.
For example attribute T-shirt Size might have range of values S - L where is attribute Shoe Size have 34-46, therefore they can be used in different product types without creating attribute from scratch in each flavor of Shoe or T-shirt product type.
Using dropdown attributes can also help to maintain consistency across the store.
Attributes vs. Metadata Difference​
Saleor uses both Attributes and Metadata in various places. Attributes have a strict structure with data types, validation, schema etc. Metadata is a simple key: value
structure without types. You might wonder, do we need both? Or which should I use where?
Attributes:
- intended to be filled in by people
- strictly typed
- the schema is strict so that the storefront can depend on this value being of a specific shape e.g. a field for number of pages will not contain a photo of jeans
- attributes are typically used in the UI layer, presented to customers, merchandisers, or admins
Metadata:
- intended to be filled by an app, an automation or integration through the API
- validation should happen in unit tests of the app
- metadata has no schema so that it doesn’t require a human to change how the code is operating with them