on 2018 Mar 19 11:25 AM
I find the CatalogSynchronizationService really developer unfriendly 🙂
Is there an example how to performSynchronization a single item synchronization ?
Most of the code I find even in the current Hybris services uses CatalogManager (from hybris 3) and JALO layer stuff.
it should be easy but it is more like an impossible task ;)
Request clarification before answering.
OK I came with the following code which uses a bit of a Jalo layer.
String catalogId = product.getCatalogVersion().getCatalog().getId();
final Catalog catalog = CatalogManager.getInstance().getCatalog(catalogId);
if (catalog != null) {
final CatalogVersion source = catalog.getCatalogVersion(CatalogManager.OFFLINE_VERSION);
final CatalogVersion target = catalog.getCatalogVersion(CatalogManager.ONLINE_VERSION);
if (source != null && target != null) {
SyncItemJob syncJob = CatalogManager.getInstance().getSyncJob(source, target);
//Convert Jalo to Model so we can use the CatalogSynchronizationService
SyncItemJobModel syncJobModel = modelService.get(syncJob);
catalogSynchronizationService.performSynchronization(Collections.singletonList(product), syncJobModel, getSyncConfig());
}
}
the syncConfig is created as fallows:
private SyncConfig getSyncConfig() {
final SyncConfig syncConfig = new SyncConfig();
syncConfig.setCreateSavedValues(Boolean.TRUE);
syncConfig.setForceUpdate(Boolean.TRUE);
syncConfig.setLogLevelDatabase(JobLogLevel.WARNING);
syncConfig.setLogLevelFile(JobLogLevel.WARNING);
syncConfig.setLogToFile(Boolean.TRUE);
syncConfig.setLogToDatabase(Boolean.FALSE);
syncConfig.setSynchronous(Boolean.FALSE);
return syncConfig;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.