Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. The Developer Center continues to support Commerce 6.13.0 through 7.4.1.Visit new site

Attributes

Attributes

Attributes enable store administrators to customize product, category, or customer profile properties without having to change the code or database schema. For example, a store administrator can add a "Megapixels" attribute to digital cameras or a "Genre" attribute to movies.

Attributes support multiple languages, so you can give language-specific values to an attribute such as product description.

Key Classes

In Core:

  • Attribute - Represents an attribute. For example, "Megapixels" or "Genre".
  • AttributeType - Represents an attribute type. For example, a "Product Description" attribute is a "Long Text" type.
  • AttributeGroup - Represents a group of attributes. For example, a movie SKU has a "Genre", and a "Product Description".
  • AttributeGroupAttribute - Wrapper for an Attribute in an AttributeGroup. Adds additional information, such as the ordering of the attributes in the attribute group.
  • AttributeUsage - Defines the domain object the attribute is applied to. For example, a "Genre" is a "PRODUCT" attribute.
  • AttributeValue - Represents an attribute value. For example, "Action", "Comedy", "Horror".
  • AttributeValueGroup - Represents a group of AttributeValues. For example, a movie SKU has the AttributeValues "Action" and "This is a movie description."
  • CategoryType - Contains an AttributeGroup that applies to categories of this CategoryType.
  • ProductType - Contains two AttributeGroups that apply to products and SKUs of this ProductType. For example, a movie's "Genre" attribute applies at the product level while the "Blu-ray" attribute applies at the SKU level.
  • AttributeMultiValueType - Specifies the encoding format of the attribute. See AttributeMultiValueType section .

AttributeType

AttributeType declares the type of the attribute values that can be assigned to the attribute. The database uses AttributeType to determine how values are persisted.

Elastic Path supports 9 attribute types for Categories, Products, Product SKUs, and Customer Profiles:

Attribute Type Possible Values
Short Text up to 255 chars, supports multiple languages
Long Text up to 65535 chars, supports multiple languages
Integer positive or negative integers
Decimal positive or negative decimals
Date date
DateTime date and time
Image an image file, such as BMP, JPEG, PNG, TIFF
File a resource file
Boolean

true or false

AttributeMultiValueType

Certain attributes may have more than one value associated. For example, the attribute "colors" may contain "Red, Blue, Yellow". The attribute value is encoded as text and can be parsed back to its elements.

AttributeMultiValueType specifies the type of encoding used if the attribute is multi-valued.

Note:

The entire encoded text cannot be longer than 65535 characters.

There are three supported types

AttributeMultiValueType Database Value ImportExport Data Value Effect

Single Value

0 false

Attribute is not a multi-value and does not need to be decoded

Legacy

1 true

Attribute is multi-valued where every value is separated by a comma. Values cannot contain commas.

ex) 'Red, Blue, Yellow' decodes to { Red, Blue, Yellow } (list of 3 elements)

RFC-4180 (CSV Encoding)

2 rfc4180

Attribute is multi-valued. Unlike Legacy encoding, values can contain commas. The value with the comma needs to be surrounded with escape quotations.

ex) ' Cengage, "Bar Publishing, Inc."' decodes to { Cengage, "Bar Publishing, Inc" } (list of 2 elements)

By default, new multi-valued attributes will be in RFC-4180 compliant encoding.