Package de.hybris.platform.product.impl
Class DefaultConfiguratorSettingsResolutionStrategy
- java.lang.Object
-
- de.hybris.platform.product.impl.DefaultConfiguratorSettingsResolutionStrategy
-
- All Implemented Interfaces:
ConfiguratorSettingsResolutionStrategy
public class DefaultConfiguratorSettingsResolutionStrategy extends java.lang.Object implements ConfiguratorSettingsResolutionStrategy
Default implementation ofConfiguratorSettingsResolutionStrategy.
-
-
Constructor Summary
Constructors Constructor Description DefaultConfiguratorSettingsResolutionStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Collection<java.util.List<CategoryModel>>getAllCategoryPathsForProduct(ProductModel product)Collects all category paths for given product.protected CategoryServicegetCategoryService()java.util.List<AbstractConfiguratorSettingModel>getConfiguratorSettingsForProduct(ProductModel product)This implementation mergesAbstractConfiguratorSettingModelof given product respecting the following rules: Settings with different qualifiers are simply combined In case of qualifier collisions the winner is the setting that is closer to the product in category hierarchy If there is a collision between setting qualifier on the same distance in category hierarchy, random one of the settings will be taken.protected java.util.List<ProductModel>getProductHierarchy(ProductModel product)protected java.util.Map<java.lang.String,AbstractConfiguratorSettingModel>getSettingsCutByIndex(java.util.Collection<java.util.List<CategoryModel>> paths, int index)Collects configurator settings from section of given category paths at given index, so for index=1 only second items (if any) of each path will be considered.protected java.util.Map<java.lang.String,AbstractConfiguratorSettingModel>getSettingsMappedByQualifier(ProductModel product)Builds a map configurator qualifier to configurator collected from all categories of given product.protected ProductModelgetSuperiorProduct(ProductModel product)protected java.util.Map<java.lang.String,AbstractConfiguratorSettingModel>mergeConfiguratorSettings(java.util.Map<java.lang.String,AbstractConfiguratorSettingModel> first, java.util.Map<java.lang.String,AbstractConfiguratorSettingModel> second)Merges one map of configurator settings into the other.protected AbstractConfiguratorSettingModelprocessConfiguratorSettingAmbiguity(AbstractConfiguratorSettingModel option1, AbstractConfiguratorSettingModel option2)The method decides which of the conflicting configurator settings to take.voidsetCategoryService(CategoryService categoryService)
-
-
-
Method Detail
-
getConfiguratorSettingsForProduct
@Nonnull public java.util.List<AbstractConfiguratorSettingModel> getConfiguratorSettingsForProduct(@Nonnull ProductModel product)
This implementation mergesAbstractConfiguratorSettingModelof given product respecting the following rules:- Settings with different qualifiers are simply combined
- In case of qualifier collisions the winner is the setting that is closer to the product in category hierarchy
- If there is a collision between setting qualifier on the same distance in category hierarchy,
random one of the settings will be taken. The behavior can be overridden
in
processConfiguratorSettingAmbiguity(de.hybris.platform.product.model.AbstractConfiguratorSettingModel, de.hybris.platform.product.model.AbstractConfiguratorSettingModel). - For variant products settings of base product are also taken according to the rules above, but with priority lower then product variant's own settings.
- The method keeps setting item order
as it has been defined in
ConfigurationCategoryModel.getConfiguratorSettings(). The list is built from root categories to leafs. Order of items from different categories of the same level is not defined, e.g., if a product has super categoriesAwith settingsA1andA2andBwith settingsB1andB2, the result list can be either[A1, A2, B1, B2]or[B1, B2, A1, A2].
- Specified by:
getConfiguratorSettingsForProductin interfaceConfiguratorSettingsResolutionStrategy- Parameters:
product- product of collect configurator settings for- Returns:
- list of configurator settings
- See Also:
ConfigurationCategoryModel
-
getProductHierarchy
protected java.util.List<ProductModel> getProductHierarchy(ProductModel product)
-
getSuperiorProduct
protected ProductModel getSuperiorProduct(ProductModel product)
-
getSettingsMappedByQualifier
@Nonnull protected java.util.Map<java.lang.String,AbstractConfiguratorSettingModel> getSettingsMappedByQualifier(@Nonnull ProductModel product)
Builds a map configurator qualifier to configurator collected from all categories of given product.- Parameters:
product- product to gather configurator settings from- Returns:
- configurations
-
getSettingsCutByIndex
@Nonnull protected java.util.Map<java.lang.String,AbstractConfiguratorSettingModel> getSettingsCutByIndex(@Nonnull java.util.Collection<java.util.List<CategoryModel>> paths, int index)
Collects configurator settings from section of given category paths at given index, so for index=1 only second items (if any) of each path will be considered.- Parameters:
paths- category pathsindex- which items of each of the paths to take- Returns:
- map of configurator settings. Key collisions are already resolved by
processConfiguratorSettingAmbiguity(AbstractConfiguratorSettingModel, AbstractConfiguratorSettingModel) - See Also:
getAllCategoryPathsForProduct(ProductModel)
-
getAllCategoryPathsForProduct
@Nonnull protected java.util.Collection<java.util.List<CategoryModel>> getAllCategoryPathsForProduct(@Nonnull ProductModel product)
Collects all category paths for given product.- Parameters:
product- product- Returns:
- category paths
-
mergeConfiguratorSettings
protected java.util.Map<java.lang.String,AbstractConfiguratorSettingModel> mergeConfiguratorSettings(@Nonnull java.util.Map<java.lang.String,AbstractConfiguratorSettingModel> first, @Nonnull java.util.Map<java.lang.String,AbstractConfiguratorSettingModel> second)
Merges one map of configurator settings into the other. Default implementation simply adds all items, overriding colliding ones.- Parameters:
first- map setting qualifier to settingsecond- map setting qualifier to setting- Returns:
- result of merging of the two maps
-
processConfiguratorSettingAmbiguity
protected AbstractConfiguratorSettingModel processConfiguratorSettingAmbiguity(AbstractConfiguratorSettingModel option1, AbstractConfiguratorSettingModel option2)
The method decides which of the conflicting configurator settings to take. Conflicting settings are the ones with the sameQualifier.The default implementation simply returns the first option.
- Parameters:
option1- first optionoption2- second option- Returns:
- the option chosen
-
getCategoryService
protected CategoryService getCategoryService()
- Returns:
- category service
-
setCategoryService
public void setCategoryService(CategoryService categoryService)
-
-