在 Shopify 中将产品发布到在线商店时出错

问题描述 投票:0回答:1

创建产品后,我尝试将其发布到在线商店。该产品即将发布,但我收到以下错误:

Error: Your app doesn't have a publication for this shop.

这是我的代码:

// Publish the newly created product.
const publishProductRequest = await admin.graphql(
  `#graphql
  mutation publishProduct($id: ID!, $input: [PublicationInput!]!) {
    publishablePublish(id: $id, input: $input) {
      userErrors {
        field
        message
      }
      publishable {
        availablePublicationCount
        publicationCount
        publishedOnCurrentPublication
      }
      shop {
        id
        name
        publicationCount
      }
    }
  }`,
  {
    variables: {
      id: productId,
      input: {
        publicationId: onlineStorePublicationId,
      },
    },
  }
);

const publishProductResponse = await publishProductRequest.json();

return json(publishProductResponse);

但是,我在 Shopify 讨论中发现了一个类似的问题,其中包含一个可接受的解决方案:应用程序需要店面 API 访问权限才能将产品设置为在线商店。但我无法理解该解决方案。

有人可以帮忙解决这个问题吗? TIA

shopify shopify-app shopify-api shopify-storefront-api
1个回答
0
投票

不要查询

publishedOnCurrentPublication
来获取
publishable
对象,它将起作用。

      publishable {
        availablePublicationCount
        publicationCount
      }
© www.soinside.com 2019 - 2024. All rights reserved.