创建产品后,我尝试将其发布到在线商店。该产品即将发布,但我收到以下错误:
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
不要查询
publishedOnCurrentPublication
来获取 publishable
对象,它将起作用。
publishable {
availablePublicationCount
publicationCount
}