Skip to content

⚡ Quick Start

1. Installation

  • Make sure you have JDK 11 installed.
  • Add the following dependency in your application:
  • For Maven users:
    <!-- Add commercetools-sync-java dependency. -->
  • For Gradle users:
    // Add commercetools-sync-java dependency.
    implementation 'com.commercetools:commercetools-sync-java:9.2.2'

2. Setup Syncing Options

final Logger logger = LoggerFactory.getLogger(MySync.class);
final ProductSyncOptions productsyncOptions = ProductSyncOptionsBuilder
                                .errorCallback((syncException, draft, productProjection, updateActions) -> 
                                   logger.error(syncException.getMessage(), syncException))
                                .warningCallback((exception, oldProductProjection, newResources) -> 
                                   logger.warn(exception.getMessage(), exception))

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()
/*"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