【问题标题】:ProductProjectionByKeyGet not retrieving Channel Reference by KeyProductProjectionByKeyGet 不按键检索通道引用
【发布时间】: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


【解决方案1】:

很遗憾,产品价格不包含渠道密钥,仅包含渠道 ID。 同步 Java 库确实提供了通道密钥解析,因此它希望您的价格草案将包含密钥。

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

这有帮助吗?

最好的问候 布赖恩

您也可以考虑使用 Import API

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

【讨论】:

    猜你喜欢
    • 2012-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-16
    • 1970-01-01
    相关资源
    最近更新 更多