When getting product details by product key from commercetools, The response that I get does not have the Channel Key as channelId
but instead I get a random UUID (I believe the reference id).
final ProductProjectionByKeyGet productProjectionByKeyGet =
ProductProjectionByKeyGet.of(productKey, ProductProjectionType.CURRENT)
.withExpansionPaths(product -> product.allVariants()
.attributes().valueSet());
return clientManager.getClientForProjectKey(ctAdapterProperties, projectKey)
.execute(productProjectionByKeyGet).toCompletableFuture().get();
In the response after getting product details, If we take a look into the property prices[].channel.id
the value for it is a UUID but inside the commercetools, I have the channel key as a string like: <store>-<online>
prices={PriceDraftDsl[
channel=Reference{
typeId='channel',
id='b5c57a89-4f18-41eb-b5c3-e0de1c09cf81',
obj=null},
country=<null>,
custom=<null>,
customerGroup=<null>,
tiers=<null>,
validFrom=<null>,
validUntil=<null>,
value=USD 12]}
When I tried to do ProductSync with the above prices, I got the following error exception.
ReferenceResolutionException: Failed to resolve 'channel'
reference on PriceDraft with country:'null' and value: 'USD 12'.
Reason: Channel with key 'b5c57a89-4f18-41eb-b5c3-e0de1c09cf81'
does not exist.
Is there any way I can get the channel's key instead of a random UUID for channelId? and if not, Can I maybe get the channel details by using this ID?
I am currently using version 1.7.0
for commercetools-sync-java
package.
I'm pretty new at this. Any help on this is deeply appreciated.
Thanks in advance!
Unfortunately, The product price does not contain channel key only a channel id. The sync java library does provide channel key resolution and so it expects that your price draft will contain the key.
Does that help?
Best Regards Brian
You might also consider using the Import API
https://docs.commercetools.com/tutorials/import-and-export#import-api