Class StockPopulator<SOURCE extends ProductModel,TARGET extends StockData>
java.lang.Object
de.hybris.platform.commercefacades.product.converters.populator.StockPopulator<SOURCE,TARGET>
- All Implemented Interfaces:
Populator<SOURCE,TARGET>
public class StockPopulator<SOURCE extends ProductModel,TARGET extends StockData>
extends Object
implements Populator<SOURCE,TARGET>
Populate the product data with stock information
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BaseSiteServiceprotected BaseStoreServiceprotected CategoryServiceprotected CommerceStockServiceprotected voidgetThresholdfromOneTree(CategoryModel currentCategory, Set<CategoryModel> processedCategories, Map<CategoryModel, Integer> thresholdOnCategory) The recursive method get the threshold value from a category tree one level up each time, it will exit the recursion when get an value from one level of category and flag all its super categories as processedprotected IntegergetThresholdValue(ProductModel productModel) Loop in all the super categories of a product belongs to, if it is a variant product, get all super categories from its base product also, then get the lowest level value from each of the categories tree, then the minimum values from all the categories trees is the threshold will be applied on a product.protected booleanprotected booleanisStockSystemEnabled(BaseStoreModel baseStore) voidPopulate the target instance with values from the source instance.voidsetBaseSiteService(BaseSiteService baseSiteService) voidsetBaseStoreService(BaseStoreService baseStoreService) voidsetCategoryService(CategoryService categoryService) voidsetCommerceStockService(CommerceStockService commerceStockService)
-
Constructor Details
-
StockPopulator
public StockPopulator()
-
-
Method Details
-
populate
Description copied from interface:PopulatorPopulate the target instance with values from the source instance.- Specified by:
populatein interfacePopulator<SOURCE extends ProductModel,TARGET extends StockData> - Parameters:
productModel- the source objectstockData- the target to fill- Throws:
ConversionException- if an error occurs
-
isStockSystemEnabled
protected boolean isStockSystemEnabled() -
isStockSystemEnabled
-
getThresholdValue
Loop in all the super categories of a product belongs to, if it is a variant product, get all super categories from its base product also, then get the lowest level value from each of the categories tree, then the minimum values from all the categories trees is the threshold will be applied on a product. If no threshold is set on any categories, then apply the default threshold value set at site level.- Parameters:
productModel-- Returns:
- the threshold value to apply on the given product
-
getThresholdfromOneTree
protected void getThresholdfromOneTree(CategoryModel currentCategory, Set<CategoryModel> processedCategories, Map<CategoryModel, Integer> thresholdOnCategory) The recursive method get the threshold value from a category tree one level up each time, it will exit the recursion when get an value from one level of category and flag all its super categories as processed- Parameters:
currentCategory-processedCategories-thresholdOnCategory- a map contains the threshold value and the category where it set from
-
getBaseStoreService
-
setBaseStoreService
-
getCommerceStockService
-
setCommerceStockService
-
getCategoryService
-
setCategoryService
-
getBaseSiteService
-
setBaseSiteService
-