Skip to content

Instantly share code, notes, and snippets.

@heshamMassoud
heshamMassoud / ProductSyncExample2.java
Created September 23, 2019 18:58
ProductSyncExample2.java
final List<ProductDraft> productDrafts = createProductDrafts();
@heshamMassoud
heshamMassoud / ProductSyncExample1.java
Last active September 23, 2019 19:34
ProductSyncExample1.java
final Logger logger = LoggerFactory.getLogger(MySync.class);
final ProductSyncOptions productsyncOptions =
ProductSyncOptionsBuilder.of(sphereClient)
.errorCallBack(logger::error)
.warningCallBack(logger::warn)
.build();
final ProductSync productSync = new ProductSync(productSyncOptions);
@heshamMassoud
heshamMassoud / ProductSyncExample.java
Last active September 23, 2019 19:34
ProductSyncExample.java
// execute the sync on your list of productDrafts
final CompletionStage<ProductSyncStatistics> syncStatisticsStage = productSync.sync(productDrafts);
final ProductSyncStatistics stats = syncStatisticsStage.toCompletebleFuture().join();
LOGGER.info(stats.getReportMessage());
/*Prints the following line: "Summary: 2000 products were processed in total (1000 created, 995 updated and 5 failed to sync)."*/
@heshamMassoud
heshamMassoud / request.json
Last active November 24, 2018 11:25
ProductDraft with non-mastervariants
{
"name": {
"de-DE": "test name with 2 non-masterVariants"
},
"productType": {
"key": "pt2",
"typeId": "product-type"
},
"slug": {
"de-DE": "test-slug-no-variants3"
@heshamMassoud
heshamMassoud / SyncSolutionInfo.java
Created November 21, 2017 14:36
Get library from properties file
public class SyncSolutionInfo extends SolutionInfo {
static final String UNSPECIFIED = "unspecified";
-
+ static final String LIBRARY_PROPERTIES = "application.properties";
+ static final String LIBRARY_NAME_PROPERTY = "name";
+ static final String LIBRARY_VERSION_PROPERTY = "version";
public SyncSolutionInfo() throws IOException, IllegalArgumentException {
final InputStream propertiesStream = SyncSolutionInfo.class.getClassLoader()
.getResourceAsStream(LIBRARY_PROPERTIES);