ProductProjectionByKeyGet 不通过键检索通道引用

ProductProjectionByKeyGet not retrieving Channel Reference by Key

当从 commercetools 通过产品密钥获取产品详细信息时,我得到的响应没有 Channel Key 作为 channelId,而是我得到 random 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.

有什么方法可以获取频道的密钥而不是 channelId 的随机 UUID?如果没有,我是否可以使用此 ID 获取频道详细信息?


我目前正在为 commercetools-sync-java 包使用版本 1.7.0
我对此很陌生。对此的任何帮助深表感谢。 提前致谢!

很遗憾,产品价格不包含频道密钥,仅包含频道 ID。 sync java 库确实提供通道密钥解析,因此它希望您的价格草案将包含该密钥。

https://github.com/commercetools/commercetools-sync-java/blob/master/docs/usage/PRODUCT_SYNC.md#syncing-from-an-external-resource

有帮助吗?

最好的问候 布莱恩

您也可以考虑使用导入 API

https://docs.commercetools.com/tutorials/import-and-export#import-api