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 Details

  • 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 of Variants from a pre-configured OptionTemplateGroup. Variants are only generated if the OptionTemplates that appear in the given OptionTemplateGroup are OptionTemplate#isVariantDistinguishing().

      All of the Variants created as a result of this operation are saved in the backing data store

      Parameters:
      skuCodePrefix - an optional prefix to assign to each Variant
      productId - Product to generate Skus for
      context - optional context that the generated Skus should appear in
      Returns:
      all of the Variants that were generated
      See Also:
    • createAndSaveVariants

      protected List<P> createAndSaveVariants(List<Set<ProductOptionValueCombination>> combinationsToCreate, Product product, @Nullable String skuCodePrefix, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildVariant

      protected P buildVariant(String skuPrefix, Set<ProductOptionValueCombination> valuesCombination, Product product)
    • generateUniqueSkuCode

      protected String generateUniqueSkuCode(String skuPrefix)
      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 product
      valuesCombination - the product option value combination used to generate this variant
      Returns:
      a name for the variant
    • getVariantSvc

      protected VariantService<Variant> getVariantSvc()
    • getProductSvc

      protected ProductService<Product> getProductSvc()
    • getCombinationSvc

      protected ProductOptionValueCombinationService 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()