Class SkuGenerationService<P extends Variant>
java.lang.Object
com.broadleafcommerce.catalog.service.product.SkuGenerationService<P>
@ConfigurationProperties("broadleaf.catalog.sku.generation")
public class SkuGenerationService<P extends Variant>
extends Object
Responsible for generating Skus for a
OptionTemplateGroup
. To customize the SKU codes
that are genereated, see generateUniqueSkuCode(String)
.- Author:
- Phillip Verheyden (phillipuniverse)
-
Constructor Summary
ConstructorDescriptionSkuGenerationService
(VariantService<Variant> variantSvc, ProductService<Product> productSvc, ProductOptionValueCombinationService combinationSvc, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.transaction.support.TransactionTemplate template) -
Method Summary
Modifier and TypeMethodDescriptionprotected P
buildVariant
(String skuPrefix, Set<ProductOptionValueCombination> valuesCombination, Product product) createAndSaveVariants
(List<Set<ProductOptionValueCombination>> combinationsToCreate, Product product, String skuCodePrefix, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) generateSkus
(String skuCodePrefix, String productId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Generate a set ofVariant
s from a pre-configuredOptionTemplateGroup
.protected String
generateUniqueSkuCode
(String skuPrefix) Extension point to customize the format of SKU codes that are generatedprotected String
generateVariantName
(Product product, Set<ProductOptionValueCombination> valuesCombination) Extension point to customize the variant names that are generatedprotected ProductOptionValueCombinationService
protected OptionTemplateService<OptionTemplate>
int
protected ProductService<Product>
protected org.springframework.transaction.support.TransactionTemplate
protected com.broadleafcommerce.common.extension.TypeFactory
protected VariantService<Variant>
void
setOptionTemplateService
(OptionTemplateService<OptionTemplate> optionTemplateService) void
setPostfixCharacters
(int postfixCharacters)
-
Constructor Details
-
SkuGenerationService
public SkuGenerationService(VariantService<Variant> variantSvc, ProductService<Product> productSvc, ProductOptionValueCombinationService combinationSvc, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.transaction.support.TransactionTemplate template)
-
-
Method Details
-
generateSkus
public List<P> generateSkus(@Nullable String skuCodePrefix, @NonNull String productId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Generate a set ofVariant
s from a pre-configuredOptionTemplateGroup
. Variants are only generated if theOptionTemplate
s that appear in the givenOptionTemplateGroup
areOptionTemplate#isVariantDistinguishing()
.All of the
Variant
s created as a result of this operation are saved in the backing data store -
createAndSaveVariants
-
buildVariant
protected P buildVariant(String skuPrefix, Set<ProductOptionValueCombination> valuesCombination, Product product) -
generateUniqueSkuCode
Extension point to customize the format of SKU codes that are generated- Parameters:
skuPrefix
- the preconfigured prefix for a SKU- Returns:
- a unique SKU code
-
generateVariantName
protected String generateVariantName(Product product, Set<ProductOptionValueCombination> valuesCombination) Extension point to customize the variant names that are generated- Parameters:
product
- the owning productvaluesCombination
- the product option value combination used to generate this variant- Returns:
- a name for the variant
-
getVariantSvc
-
getProductSvc
-
getOptionTemplateService
-
setOptionTemplateService
@Autowired public void setOptionTemplateService(OptionTemplateService<OptionTemplate> optionTemplateService) -
getCombinationSvc
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getTemplate
protected org.springframework.transaction.support.TransactionTemplate getTemplate() -
setPostfixCharacters
public void setPostfixCharacters(int postfixCharacters) -
getPostfixCharacters
public int getPostfixCharacters()
-