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 Object
implements ConfiguratorSettingsResolutionStrategy
Default implementation of
ConfiguratorSettingsResolutionStrategy.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<List<CategoryModel>>Collects all category paths for given product.protected CategoryServiceThis 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 List<ProductModel>getProductHierarchy(ProductModel product) protected Map<String,AbstractConfiguratorSettingModel> getSettingsCutByIndex(Collection<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 Map<String,AbstractConfiguratorSettingModel> getSettingsMappedByQualifier(ProductModel product) Builds a map configurator qualifier to configurator collected from all categories of given product.protected ProductModelgetSuperiorProduct(ProductModel product) protected Map<String,AbstractConfiguratorSettingModel> mergeConfiguratorSettings(Map<String, AbstractConfiguratorSettingModel> first, Map<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)
-
Constructor Details
-
DefaultConfiguratorSettingsResolutionStrategy
public DefaultConfiguratorSettingsResolutionStrategy()
-
-
Method Details
-
getConfiguratorSettingsForProduct
@Nonnull public 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:
-
getProductHierarchy
-
getSuperiorProduct
-
getSettingsMappedByQualifier
@Nonnull protected Map<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 Map<String,AbstractConfiguratorSettingModel> getSettingsCutByIndex(@Nonnull Collection<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
@Nonnull protected Collection<List<CategoryModel>> getAllCategoryPathsForProduct(@Nonnull ProductModel product) Collects all category paths for given product.- Parameters:
product- product- Returns:
- category paths
-
mergeConfiguratorSettings
protected Map<String,AbstractConfiguratorSettingModel> mergeConfiguratorSettings(@Nonnull Map<String, AbstractConfiguratorSettingModel> first, @Nonnull Map<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
- Returns:
- category service
-
setCategoryService
-