Package de.hybris.platform.product
Interface VariantsService
-
- All Known Subinterfaces:
BackofficeVariantsService
- All Known Implementing Classes:
DefaultBackofficeVariantsService
,DefaultVariantsService
public interface VariantsService
Service to provide generic access to variant product attributes. This is necessary because variant product types may be created during runtime and therefore no actual model class is available providing appropriate attribute accessor methods.- Spring Bean ID:
- variantsService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Collection<VariantTypeModel>
getAllVariantTypes()
Searches all existing variant types.java.util.Map<java.lang.String,java.util.Collection<java.lang.Object>>
getAssignedVariantAttributes(ProductModel baseProduct)
Searches variant attributes with all assigned values for given base product.java.util.Set<java.lang.String>
getVariantAttributes(java.lang.String variantProductType)
Returns a set of variant attribute qualifiers for the givenvariantProductType
.java.util.List<VariantAttributeDescriptorModel>
getVariantAttributesForVariantType(VariantTypeModel variantType)
Returns the attribute descriptors of the givenVariantType
.java.lang.Object
getVariantAttributeValue(VariantProductModel variant, java.lang.String qualifier)
Returns for the givenVariantProductModel
and given attributequalifier
the value of this attribute.java.util.Collection<VariantProductModel>
getVariantProductForAttributeValues(ProductModel baseProduct, java.util.Map<java.lang.String,java.lang.Object> filterValues)
Filters a range of variants from a given base product according to the given variant attribute qualifier-value map.VariantTypeModel
getVariantTypeForCode(java.lang.String code)
Returns aVariantTypeModel
instance for the givencode
.void
setVariantAttributesForVariantType(VariantTypeModel variantType, java.util.List<VariantAttributeDescriptorModel> newAttributes)
Tries to assign new variant attribute descriptors for the given variant type.void
setVariantAttributeValue(VariantProductModel variant, java.lang.String qualifier, java.lang.Object value)
-
-
-
Method Detail
-
getVariantTypeForCode
VariantTypeModel getVariantTypeForCode(java.lang.String code)
Returns aVariantTypeModel
instance for the givencode
.- Parameters:
code
- the variant type code. Must exists in the system and must be not null.- Returns:
- a VariantTypeModel for the given code.
- Throws:
UnknownIdentifierException
- if there is no VariantTypeModel for given codejava.lang.IllegalArgumentException
- if givencode
is null
-
getVariantAttributes
java.util.Set<java.lang.String> getVariantAttributes(java.lang.String variantProductType)
Returns a set of variant attribute qualifiers for the givenvariantProductType
.- Parameters:
variantProductType
- the variant type code. Must exists in the system and must be a variant type.- Returns:
- an empty set if for the given
variantProductType
no variant attributes were found. - Throws:
UnknownIdentifierException
- if the givenvariantProductType
does not exists or is not a variant type
-
getVariantAttributeValue
java.lang.Object getVariantAttributeValue(VariantProductModel variant, java.lang.String qualifier)
Returns for the givenVariantProductModel
and given attributequalifier
the value of this attribute.- Parameters:
variant
- the variant productqualifier
- the attribute qualifier- Returns:
- what is stored in this attribute.
- Throws:
SystemException
- if the attribute couldn't be read
-
setVariantAttributeValue
void setVariantAttributeValue(VariantProductModel variant, java.lang.String qualifier, java.lang.Object value)
- Parameters:
variant
- the variant productqualifier
- the attribute qualifiervalue
- the value to be set- Throws:
SystemException
- if the attribute couldn't be written
-
getAllVariantTypes
java.util.Collection<VariantTypeModel> getAllVariantTypes()
Searches all existing variant types.- Returns:
- the variant types.
-
getAssignedVariantAttributes
java.util.Map<java.lang.String,java.util.Collection<java.lang.Object>> getAssignedVariantAttributes(ProductModel baseProduct)
Searches variant attributes with all assigned values for given base product.- Parameters:
baseProduct
- the base product for all variants- Returns:
- map "name of attribute (qualifier) ->distinct values" over all variants
-
getVariantProductForAttributeValues
java.util.Collection<VariantProductModel> getVariantProductForAttributeValues(ProductModel baseProduct, java.util.Map<java.lang.String,java.lang.Object> filterValues)
Filters a range of variants from a given base product according to the given variant attribute qualifier-value map. If not all available attributes are specified the method is likely to return more than one variant - if all attributes are specified there should be only one variant which matches them.- Parameters:
baseProduct
- the base product to get variants forfilterValues
- the variant attribute values (attribute qualifier->value map) to match. ifnull or empty
an empty List will be returned.- Returns:
- collection of matching variants.
-
getVariantAttributesForVariantType
java.util.List<VariantAttributeDescriptorModel> getVariantAttributesForVariantType(VariantTypeModel variantType)
Returns the attribute descriptors of the givenVariantType
.- Parameters:
variantType
- the variant type- Returns:
- an attributes collection
-
setVariantAttributesForVariantType
void setVariantAttributesForVariantType(VariantTypeModel variantType, java.util.List<VariantAttributeDescriptorModel> newAttributes)
Tries to assign new variant attribute descriptors for the given variant type. Removes old attributes if necessary and checks if enclosing type is set correctly. This is achieved by internal save of the given variantType with new set of theVariantAttributeDescriptorModel
s.- Parameters:
variantType
- the variant typenewAttributes
- the attributes which should be assigned- Throws:
java.lang.IllegalArgumentException
- if given variantType is new
-
-