Class representing the complete variation information for a master product in
the system. An instance of this class provides methods to access the
This model only considers variants which are complete (i.e. the variant has a
value for each variation attribute), and currently online. Incomplete or
offline variants will not be returned by any method that returns Variants,
and their attribute values will not be considered in any method that returns
In addition to providing access to this meta information,
ProductVariationModel maintains a collection of selected variation attribute
values, representing the selections that a customer makes in the storefront.
If this model was constructed for a master product, then none of the
attributes will have pre-selected values. If this model was constructed for a
variant product, then all the attribute values of that variant will be
It is possible to query the current selections by calling
The method setSelectedAttributeValue(String, String)
can be used to modify
the selected values. Depending on the product type, it's possible to select or modify
variation attribute values:
- If this model was constructed for a master product, it's possible to select and modify all variation attributes.
- If this model was constructed for a variation group, it's possible to select and modify all variation attributes that are not defined by the variation group.
- If this model was constructed for a variation product, it's not possible to select or modify any of the variation attributes.
Furthermore, the model provides helper methods to generate URLs
for selecting and unselecting variation attribute values. See those methods
If this model was constructed for a product that is neither a
master nor a variant, then none of the methods will return useful values at
The methods in this class which access the currently selected variation
attribute values can be used on product detail pages to render information
about which combinations are available or unavailable. The methods
can be used to determine this type of situation and render the appropriate
message in the storefront.
NOTE: Several methods in this class have a version taking a
parameter, and another
deprecated version accepting a ObjectAttributeDefinition
parameter instead. The former should be strictly favored. The latter are
historical leftovers from when object attributes were used directly as the
basis for variation, and the value lists were stored directly on the
ObjectAttributeDefinition. Every ProductVariationAttribute corresponds with
exactly one ObjectAttributeDefinition, but values are now stored on the
ProductVariationAttribute and not the ObjectAttributeDefinition.