*Added in Broadleaf 1.8.2
The ProductOption domain encapsulates additional, structured information a seller wants to capture from a customer during the ordering process. This information can be necessary for distinguishing particular variants such as shirt size, color, or material, or it can be some custom user-input like a name to emboss on the back of a jersey. As such, ProductOptions support specifying a set of allowed values that conform to a specific type—validation for those allowed values is supported.
Moreover, a ProductOption can be configured so that the customer can select from a set of products or variants directly such as for a configurable bundle. In such cases, this domain allows specifying minimum and maximum selectable quantities per item in the bundle as well setting pricing that overrides the selected item’s usual pricing when merchandised separately. The price of the item can even be marked as already included in the parent bundle’s.
OptionTemplates provide a means to persist ProductOptions independent of any Product to aid in reuse. Additionally, OptionTemplateGroups have been provided to aggregate related OptionTemplates. When ProductOptions are added via an OptionTemplate, they may be added by reference at generation.
When added by reference, the ProductOption’s templateContextId
will hold a reference to the ID of the template.
A flag will also be set on the option indicating it should be hydrated from the template before being returned to a caller.
Hydration is configured to take place when Products are retrieved for commerce, admin, and indexer requests.
With this method, any changes made to the template will be reflected by the options that reference it, and the option will be read-only from the Product management view.
Otherwise, a copy of the ProductOption will be embedded in the Product, meaning that changes to the template will not affect options previously generated from it, and that the option will be managed from the product.
Tip
|
See the Catalog Service’s product details documentation to learn more about how Broadleaf handles product details hydration. |
Since ProductOptions tend to be used in distinguishing Variants, it is common to allow automatic generation of Variants based on the options added to a Product.
To specify that a ProductOption should be used to distinguish variants, simply set that option’s type
to VARIANT_DISTINGUISHING
.
This means that there should exist a unique variant for every combination of each option’s allowedValues
.
Therefore, if a there is a "shirt" product that has "size" (Small, Medium, Large) and "color" (Black, White, Red) options and each option is set to be used in variant distinguishing, then there should exist 9 variants:
Small Black
Small White
Small Red
Medium Black
Medium White
Medium Red
Large Black
Large White
Large Red
The OptionTemplate domain allows the creation of ProductOptions from a template, allowing users to avoid recreating the same option for multiple products over and over again. Often, these are grouped into an OptionTemplateGroup to provide a sort of product type. For instance if you are selling T-Shirts, all of the T-shirts might have a product option "size" and "color", but they all have the same sizes and same colors. This might be configured with an OptionTemplateGroup of "T-shirts", that contain a 'Size' and 'Color' template, used to create products off of.
Important
|
If a ProductOption's addedByReference is true , the options generated from the template will be kept in sync with changes to the template.
Otherwise, the ProductOption will not be affected by the template.
|
Field | Description |
---|---|
ID |
Unique row ID |
CONTEXT_ID |
Logical ID. Allows for sandbox versions. |
NAME |
The friendly name of the template |
PREFER_ADD_BY_REF |
Sets the default preference for this template when associated with a product.
This can be overridden when the template is associated with a Product.
If the option is generated from a template, |
OPTION_TEMPLATE_CONTEXT_ID |
When a ProductOption is stored on a Product after being generated from an OptionTemplate, this is the ID of the template it came from. This can be used to allow synchronization between the template and options generated from it. |
OPTION_LABEL |
Text shown to customers when displaying this option such as on a product details page. |
OPTION_TYPE |
Determines the kind of option to generate: Variant distinguishing, item choice, cart item attribute, or cart attribute. This controls how a customer selects or inputs values and how this option is stored on a cart. |
OPTION_DISPLAY_ORDER |
The order relative to other options in which this option should be displayed to a customer. |
OPTION_PRODUCT_CONTEXT_ID |
When a ProductOption is stored on a Product after being generated from an OptionTemplate, this is the ID of the owning Product. |
IS_OPTION_SEARCHABLE |
If true, Product Options of |
IC_CHOICE_KEY |
Unique identifier for the option when the |
IC_TARGET_TYPE |
Defines the type of item being chosen when |
IC_SELECTION_TYPE |
Defines the type of selection a customer can make when choosing item choices.
This can be |
IC_MAXIMUM_QUANTITY |
When the option’s |
IC_MINIMUM_QUANTITY |
When the option’s |
IC_PRICING_MODEL |
Defines how to price the item choice(s) in regard to the Product that owns ProductOption.
Default models are |
IC_OVERRIDE_PRICE |
Defines the unit price for the item choices if the |
IC_DISCOUNT_ALLOWED |
If the |
IC_PRICING_KEY |
If the |
IC_DEFAULT_PRODUCT_CONTEXT_D |
When the option’s |
IC_DEFAULT_VARIANT_CONTEXT_ID |
When the option’s |
IC_DEFAULT_PROD_IN_CAT_CTX_ID |
When the option’s |
IC_CATEGORY_CONTEXT_ID |
When the option’s |
IC_SPECIFIC_CHOICES |
When the option’s |
AC_ATTRIBUTE_NAME |
When the option’s |
AC_TYPE |
When the option’s |
AC_REQUIRED |
When the option’s |
AC_VALIDATION_STRATEGY |
When the option’s |
AC_VALIDATION_TYPE |
When the option’s |
AC_VALIDATION_RULE |
If |
AC_ERROR_MESSAGE |
If the validation fails, this is the message to display. |
AC_ERROR_CODE |
If the validation fails, this is the associated error code. This could also be used as a message key. |
AC_ALLOWED_VALUES |
When the option’s |
Field | Description |
---|---|
ID |
Unique row ID |
CONTEXT_ID |
Logical ID. Allows for sandbox versions. |
NAME |
The friendly name of the template group |
TEMPLATE_CONTEXT_IDS |
Context IDs of the OptionTemplates included in this group |
OptionTemplate and OptionTemplateGroup entities are Catalog Trackable, which includes Sandbox Trackable behavior.