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
ConstructorsConstructorDescriptionSkuGenerationService(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 PbuildVariant(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 ofVariants from a pre-configuredOptionTemplateGroup.protected StringgenerateUniqueSkuCode(String skuPrefix) Extension point to customize the format of SKU codes that are generatedprotected StringgenerateVariantName(Product product, Set<ProductOptionValueCombination> valuesCombination) Extension point to customize the variant names that are generatedprotected ProductOptionValueCombinationServiceintprotected ProductService<Product>protected org.springframework.transaction.support.TransactionTemplateprotected com.broadleafcommerce.common.extension.TypeFactoryprotected VariantService<Variant>voidsetPostfixCharacters(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 ofVariants from a pre-configuredOptionTemplateGroup. Variants are only generated if theOptionTemplates that appear in the givenOptionTemplateGroupareOptionTemplate#isVariantDistinguishing().All of the
Variants 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
-
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()
-