【问题标题】:How to properly add linked Items to a List of already existing linked items with Kentico Cloud Management API如何使用 Kentico Cloud Management API 将链接项目正确添加到现有链接项目列表中
【发布时间】:2019-06-24 13:18:47
【问题描述】:

在 Kentico Cloud 中,我得到了一个包含链接项目列表的项目。但是,应该使用 Kentico Cloud Management API 从外部编辑此列表。有没有办法在不更新整个列表的情况下简单地将项目添加到此列表中?

我正在使用 C# 中的 Kentico Cloud SDK,到目前为止,我尝试使用新的 ContentItemIdentifier.byId 数组更新语言变体,但每当我调用它时,它都会覆盖我已经存在的列表。

private async Task AddOrderToDay(string orderItemExternalId, Guid dayId)
{
    ContentItemVariantIdentifier ident = new ContentItemVariantIdentifier(
        ContentItemIdentifier.ById(dayId),
        LanguageIdentifier.DEFAULT_LANGUAGE);

    UpdateOrdersDay update = new UpdateOrdersDay
    {
        Orders = 
           new[]{ContentItemIdentifier.ByExternalId(orderItemExternalId)}
    };

    ContentItemVariantModel<UpdateOrdersDay> response =
        await this._cmclient.UpsertContentItemVariantAsync(ident, update);
}

我希望我的新元素被添加到 Cloud 中现有的元素列表中。

目前它只是覆盖它们。 我尝试了一个解决方法:我调用交付 Api 来接收当前项目并将它们添加到新的新 [] {old1,old2,新 ItemIdentifier}。但是,此解决方案的性能不是很好。

【问题讨论】:

    标签: kentico-kontent


    【解决方案1】:

    目前,CM API(包括 v2)不支持逐个添加/删除链接项。

    当您从 Delivery API 而非 CM API 获取商品时,您目前正在做的是最有效的方式。

    这可能会在未来发生变化,但现在您必须在保存项目之前提出额外的请求。

    【讨论】:

      猜你喜欢
      • 2021-12-23
      • 2015-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-05
      • 1970-01-01
      • 2021-08-25
      相关资源
      最近更新 更多