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 TypeMethodDescriptionboolean
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, generateAndAddCompletions, generateAndAddCompletions, generateAndAddValidationErrorCompletions, getCompletionError, getFormattedEmbeddedValidationErrorString, getFormattedValidationErrorString, getHydrator, persist, persist, removeAndReturnFieldErrorsUnderPath
-
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
-
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
-
getDataRouteKey
-
getDUPLICATE_SKU_ERROR
-
getNOT_PROCESSED_RECORD
-
getSKU
-
getProductService
-
getVariantService
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-