【发布时间】:2021-05-30 05:14:41
【问题描述】:
当通过 commercetools 的产品密钥获取产品详细信息时,我得到的响应没有 Channel Key 作为channelId,而是我得到了一个随机 UUID (我相信参考id)。
final ProductProjectionByKeyGet productProjectionByKeyGet =
ProductProjectionByKeyGet.of(productKey, ProductProjectionType.CURRENT)
.withExpansionPaths(product -> product.allVariants()
.attributes().valueSet());
return clientManager.getClientForProjectKey(ctAdapterProperties, projectKey)
.execute(productProjectionByKeyGet).toCompletableFuture().get();
在获取产品详细信息后的响应中,如果我们查看属性prices[].channel.id,它的值是一个 UUID,但在 commercetools 中,我将通道键作为字符串,例如:<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]}
当我尝试使用上述价格进行 ProductSync 时,出现以下错误异常。
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.
有什么方法可以获取频道的密钥,而不是获取频道 ID 的随机 UUID?如果没有,我是否可以使用此 ID 获取频道详细信息?
我目前正在为commercetools-sync-java 包使用版本1.7.0。
我对此很陌生。对此的任何帮助深表感谢。
提前致谢!
【问题讨论】:
-
" ... 没有像
channelId这样的 Channel Key。" 资源 Key 和资源 ID 是存在的两个不同的东西每个 commercetools 资源。为什么您希望这些值相同?
标签: commercetools