【问题标题】:Shopify API post one product in multiple collectionsShopify API 在多个集合中发布一个产品
【发布时间】:2018-02-05 08:50:20
【问题描述】:

我们在 Shopify 中管理一个市场,并且我们正在打很多电话。我们希望提高调用次数,其中一个关键点是当我们在集合中引入产品时。一个产品可以插入多个集合中,我们为每个帖子/集合执行此操作:

public function pushCollection($shopifyProductId, $collectionId)
    {
        $collectData = [
            "product_id" => $shopifyProductId,
            "collection_id" => $collectionId
        ];
        $this->client->Collect()->post($collectData);

        return;
    }

问题是,有没有办法通过一次调用将 1 个产品发布到多个集合中?

非常感谢

【问题讨论】:

    标签: api collections shopify product


    【解决方案1】:

    你不能那样做。但是,如果您可以累积产品以添加到集合中,则可以在一次调用中将多个产品添加到集合中。

    https://help.shopify.com/api/reference/customcollection#update

    【讨论】:

    • 好的,非常感谢!我认为这将是方式。您知道一次调用中是否有最大数量的产品可以添加吗?
    【解决方案2】:

    我回答得有点晚了,但是您可以使用 Shopify 的 GraphQL API 在一个 API 调用中将一个产品添加到多个集合中。这是它的文档:https://help.shopify.com/en/api/graphql-admin-api/reference/mutation/productcreate

    将现有产品添加到现有多个集合的 GraphQL API 调用如下所示:

    mutation {
              productUpdate( input:
                {
                $id:"gid://shopify/Product/{shopifyProductId}"
        collectionsToJoin:["gid://shopify/Collection/{collectionId1}","gid://shopify/Collection/{collectionId2}" ]
                })
                {
                    product{
                        id
                    }
                }
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-31
      • 2015-12-19
      • 1970-01-01
      • 2019-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多