Skip to content

Commit a7ba829

Browse files
committed
DEVX-640: fixing transformations
1 parent 8ff084f commit a7ba829

File tree

1 file changed

+10
-3
lines changed
  • commercetools/commercetools-importapi-utils/src/main/java/com/commercetools/sdk

1 file changed

+10
-3
lines changed

commercetools/commercetools-importapi-utils/src/main/java/com/commercetools/sdk/ProductUtil.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,21 @@ private static ProductVariantDraftImport extractProductVariantDraftImport(Produc
5252
.setImages(i -> (Image) variant.getImages())
5353
.prices(variant.getPrices().stream().map(p -> PriceDraftImport.builder().key(p.getKey()).value(v ->
5454
(p.getValue() instanceof CentPrecisionMoney) ?
55-
v.centPrecisionBuilder().centAmount(p.getValue().getCentAmount()).currencyCode(p.getValue().getCurrencyCode()).fractionDigits(p.getValue().getFractionDigits()) :
56-
v.highPrecisionBuilder().centAmount(p.getValue().getCentAmount()).currencyCode(p.getValue().getCurrencyCode()).fractionDigits(p.getValue().getFractionDigits())
55+
v.centPrecisionBuilder().centAmount(p.getValue().getCentAmount()).currencyCode(p.getValue()
56+
.getCurrencyCode()).fractionDigits(p.getValue().getFractionDigits()) :
57+
v.highPrecisionBuilder().centAmount(p.getValue().getCentAmount()).currencyCode(p.getValue()
58+
.getCurrencyCode()).fractionDigits(p.getValue().getFractionDigits())
5759
).build()).collect(Collectors.toList()))
5860
.attributes(variant.getAttributes().stream().map(
5961
ProductUtil::mapAttribute).collect(Collectors.toList()))
60-
.assets(variant.getAssets());
62+
.assets(importAssets(variant.getAssets())).build();
6163
}
6264

65+
private static List<com.commercetools.importapi.models.common.Asset> importAssets(List<com.commercetools.api.models.common.Asset> assets){
66+
return assets.stream().map(a -> com.commercetools.importapi.models.common.Asset.builder().key(a.getKey())
67+
.name((com.commercetools.importapi.models.common.LocalizedString)a.getName()).build()).collect(
68+
Collectors.toList());
69+
}
6370
private static CategoryKeyReference extractCategoryKeyReference(ProductProjection product) {
6471
return CategoryKeyReference.builder().key(product.getCategories().get(0).getObj().getKey()).build();
6572
}

0 commit comments

Comments
 (0)