⚡ Quick Start¶
1. Installation¶
- Make sure you have
JDK 11
or higher installed. - Add the following dependency in your application:
- For Maven users:
<!-- Add commercetools-sync-java dependency. --> <dependency> <groupId>com.commercetools</groupId> <artifactId>commercetools-sync-java</artifactId> <version>10.0.4</version> </dependency>
- For Gradle users:
// Add commercetools-sync-java dependency. implementation 'com.commercetools:commercetools-sync-java:10.0.4'
2. Setup Syncing Options¶
final Logger logger = LoggerFactory.getLogger(MySync.class);
final ProductSyncOptions productsyncOptions = ProductSyncOptionsBuilder
.of(projectApiRoot)
.errorCallback((syncException, draft, productProjection, updateActions) ->
logger.error(syncException.getMessage(), syncException))
.warningCallback((exception, oldProductProjection, newResources) ->
logger.warn(exception.getMessage(), exception))
.build();
3. Start Syncing¶
// Transform your product feed batch into a list of ProductDrafts using your preferred way.
final List<ProductDraft> productDraftsBatch = ...
final ProductSync productSync = new ProductSync(productSyncOptions);
// execute the sync on your list of products
final CompletionStage<ProductSyncStatistics> syncStatisticsStage = productSync.sync(productDraftsBatch);
4. And you're done ✨¶
final ProductSyncStatistics stats = syncStatisticsStage.toCompletebleFuture()
.join();
stats.getReportMessage();
/*"Summary: 2000 product(s) were processed in total (1000 created, 995 updated, 5 failed to sync and 0
product(s) with missing reference(s))."*/
More Details¶
Product Sync, ProductType Sync, Category Sync, Inventory Sync, Type Sync, CartDiscount Sync, TaxCategory Sync, State Sync, CustomObject Sync, Customer Sync, ShoppingLists Sync