Class UpdatePricesImportBatchHandler
java.lang.Object
com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler
com.broadleafcommerce.catalog.dataimport.prices.UpdatePricesImportBatchHandler
- All Implemented Interfaces:
com.broadleafcommerce.common.dataimport.ImportBatchHandler
public class UpdatePricesImportBatchHandler
extends com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler
Updates the product and variant prices. The "sku" column is required.
- Author:
- Dima Myroniuk (dmyroniuk)
-
Field Summary
-
Constructor Summary
ConstructorDescriptionUpdatePricesImportBatchHandler
(com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator hydrator, ProductService<Product> productService, VariantService<Variant> variantService, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyPricingUpdatesToProduct
(@NonNull Product original, @NonNull Product updateRecord) protected void
applyPricingUpdatesToVariant
(@NonNull Variant original, @NonNull Variant updateRecord) boolean
canHandle
(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch) protected static String
protected static String
protected com.fasterxml.jackson.databind.ObjectMapper
protected ProductService<Product>
protected static String
getSKU()
protected VariantService<Variant>
groupRecordsBySku
(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions) com.broadleafcommerce.common.dataimport.messaging.BatchCompletion
handle
(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch) Updates the product and variant prices.protected void
updateProductPrices
(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions, Map<String, com.broadleafcommerce.common.dataimport.messaging.BatchRecord> recordBySkus) Updates the product prices.protected void
updateVariantPrices
(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions, Map<String, com.broadleafcommerce.common.dataimport.messaging.BatchRecord> recordBySkus) Updates the variant prices.Methods inherited from class com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler
addFailedConversionCompletions, buildAndAddCompletionRecords, buildContextInfo, buildCreateContextInfo, buildNonValidationErrorCompletions, buildReadContextInfo, buildSuccessfulCompletionsForRequest, buildUpdateContextInfo, buildValidationErrorCompletions, failRecordAndDependentsEarly, finalizeContextForBatch, generateAndAddCompletions, generateAndAddCompletions, generateAndAddValidationErrorCompletions, getBatchContextHelper, getCompletionError, getFormattedEmbeddedValidationErrorString, getFormattedValidationErrorString, getHydrator, getImportContextConfigurationProperties, getImportContextProperties, initializeContextForBatch, persist, persist, removeAndReturnFieldErrorsUnderPath, setBatchContextHelper, setImportContextConfigurationProperties
-
Field Details
-
UPDATE_PRICES_IMPORT_TYPE
- See Also:
-
-
Constructor Details
-
UpdatePricesImportBatchHandler
public UpdatePricesImportBatchHandler(com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator hydrator, ProductService<Product> productService, VariantService<Variant> variantService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
canHandle
public boolean canHandle(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch) -
handle
@SuppressNotification("SINGLE_INDEX_REQUEST") public com.broadleafcommerce.common.dataimport.messaging.BatchCompletion handle(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch) Updates the product and variant prices. If the batch contains records with duplicate SKUs, the records will be processed only once, and other records will be marked as invalid. If there are no products or variants with the specified SKU the records will be marked as invalid.- Parameters:
batch
- a batch of records that this handler should deal with- Returns:
- the result of handling a batch
-
groupRecordsBySku
-
updateProductPrices
protected void updateProductPrices(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions, Map<String, com.broadleafcommerce.common.dataimport.messaging.BatchRecord> recordBySkus) Updates the product prices. Note: This method removes the processed records from the "recordBySkus" map. This is needed to track the unprocessed records.- Parameters:
batch
- a batch of records that this handler should deal withallCompletions
- contains completed recordsrecordBySkus
- the map of the records grouped by the sku
-
applyPricingUpdatesToProduct
protected void applyPricingUpdatesToProduct(@NonNull @NonNull Product original, @NonNull @NonNull Product updateRecord) Applies the changes from theupdateRecord
to theoriginal
Product
. This ensures that only pricing fields are modified.- Parameters:
original
- The original product in the system.updateRecord
- The product that was deserialized from the import record containing the updated pricing values.
-
updateVariantPrices
protected void updateVariantPrices(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions, Map<String, com.broadleafcommerce.common.dataimport.messaging.BatchRecord> recordBySkus) Updates the variant prices. Note: This method removes the processed records from the "recordBySkus" map. This is needed to track the unprocessed records.- Parameters:
batch
- a batch of records that this handler should deal withallCompletions
- contains completed recordsrecordBySkus
- the map of the records grouped by the sku
-
applyPricingUpdatesToVariant
protected void applyPricingUpdatesToVariant(@NonNull @NonNull Variant original, @NonNull @NonNull Variant updateRecord) Applies the changes from theupdateRecord
to theoriginal
Variant
. This ensures that only pricing fields are modified.- Parameters:
original
- The original variant in the system.updateRecord
- The variant that was deserialized from the import record containing the updated pricing values.
-
getDataRouteKey
-
getDUPLICATE_SKU_ERROR
-
getNOT_PROCESSED_RECORD
-
getSKU
-
getProductService
-
getVariantService
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-