File tree Expand file tree Collapse file tree
commercetools/commercetools-importapi-utils/src/main/java/com/commercetools/sdk Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,7 +66,29 @@ public ProductDraftImport toProductDraftImport(ProductProjection product) {
6666 }
6767
6868 public ProductImport toProductImport (ProductProjection product ) {
69-
69+ var productImport = ProductImport .builder ()
70+ .key (product .getKey ())
71+ .productType (p -> p .key (keyResolverService .resolveKey (product .getProductType ())))
72+ .name (l -> getLocalizedStringBuilder (product .getName ()))
73+ .slug (l -> getLocalizedStringBuilder (product .getSlug ()))
74+ .description (Optional .ofNullable (product .getDescription ())
75+ .map (CommonImportUtil ::getLocalizedStringBuilder )
76+ .map (LocalizedStringBuilder ::build )
77+ .orElse (null ))
78+ .categories (extractCategoryKeyReference (product ))
79+ .metaTitle (Optional .ofNullable (product .getMetaTitle ())
80+ .map (CommonImportUtil ::getLocalizedStringBuilder )
81+ .map (LocalizedStringBuilder ::build )
82+ .orElse (null ))
83+ .metaDescription (
84+ (com .commercetools .importapi .models .common .LocalizedString ) product .getMetaDescription ())
85+ .metaKeywords ((com .commercetools .importapi .models .common .LocalizedString ) product .getMetaKeywords ())
86+ .taxCategory (getTaxCategoryKeyReference (product ))
87+ .state (getStateKeyReference (product ))
88+ .priceMode (mapPriceModeToImportApi (product ))
89+ .attributes (
90+ product .getAttributes ().stream ().map (ProductUtil ::mapAttribute ).collect (Collectors .toList ()));
91+ return productImport .build ();
7092 }
7193
7294 private com .commercetools .importapi .models .common .ProductPriceModeEnum mapPriceModeToImportApi (
You can’t perform that action at this time.
0 commit comments