File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
src/main/java/com/commercetools/sync/customers/utils Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ private static CustomerDraft mapToCustomerDraft(
111111 .dateOfBirth (customer .getDateOfBirth ())
112112 .isEmailVerified (customer .getIsEmailVerified ())
113113 .vatId (customer .getVatId ())
114- .addresses (mapToAddressesDraft (customer .getAddresses ()))
114+ .addresses (mapToAddressesDraft (customer .getAddresses (), referenceIdToKeyCache ))
115115 .defaultBillingAddress (
116116 getAddressIndex (customer .getAddresses (), customer .getDefaultBillingAddressId ()))
117117 .billingAddresses (
@@ -143,7 +143,9 @@ private static CustomerGroupResourceIdentifier mapToCustomerGroupResourceIdentif
143143 return null ;
144144 }
145145
146- private static List <BaseAddress > mapToAddressesDraft (@ Nonnull List <Address > addresses ) {
146+ private static List <BaseAddress > mapToAddressesDraft (
147+ @ Nonnull List <Address > addresses ,
148+ @ Nonnull final ReferenceIdToKeyCache referenceIdToKeyCache ) {
147149 if (addresses .isEmpty ()) {
148150 return emptyList ();
149151 }
@@ -178,8 +180,9 @@ private static List<BaseAddress> mapToAddressesDraft(@Nonnull List<Address> addr
178180 .externalId (address .getExternalId ());
179181
180182 if (address .getCustom () != null ) {
181- builder .custom (
182- CustomFieldsDraftBuilder .of ().fields (address .getCustom ().getFields ()).build ());
183+ CustomFieldsDraft draft =
184+ mapToCustomFieldsDraft (address .getCustom (), referenceIdToKeyCache );
185+ builder .custom (draft );
183186 }
184187 return builder .build ();
185188 })
Original file line number Diff line number Diff line change 33import static java .util .stream .Collectors .toSet ;
44
55import com .commercetools .api .client .ProjectApiRoot ;
6+ import com .commercetools .api .models .common .Address ;
67import com .commercetools .api .models .common .Reference ;
78import com .commercetools .api .models .customer .Customer ;
89import com .commercetools .api .models .customer .CustomerDraft ;
@@ -84,6 +85,17 @@ private CompletableFuture<Void> transformCustomTypeReference(
8485 .map (Reference ::getId )
8586 .collect (toSet ());
8687
88+ final Set <String > setOfAddressCustomTypeIds =
89+ customers .stream ()
90+ .flatMap (c -> c .getAddresses ().stream ())
91+ .map (Address ::getCustom )
92+ .filter (Objects ::nonNull )
93+ .map (CustomFields ::getType )
94+ .map (Reference ::getId )
95+ .collect (toSet ());
96+
97+ setOfTypeIds .addAll (setOfAddressCustomTypeIds );
98+
8799 return fetchAndFillReferenceIdToKeyCache (setOfTypeIds , GraphQlQueryResource .TYPES );
88100 }
89101
You can’t perform that action at this time.
0 commit comments