Development discussions around Shopify APIs
Right now, all the products in my online store are getting added via ascript that uses GraphQL API.
Yet I just realized that none of the products are getting showed on the store itself.
I modifed one product, and in "Product Availability" I added "Online Store".
I believe this is the "sales channel".
At the moment that single product shows up on the online store.
Yet how can I add via GraphQL API all products to the online store?
The script I created uses the mutation productCreate.
That mutation uses an input object called ProductInput.
On the input fields, there is a field called productPublications which has the information:
A list of the channels where the product is published. This argument is deprecated: Use PublishablePublish instead.
So... MY DOUBT:
Do I have to use instead the new mutation publishablePublish?
This page for publishablePublish (link above) tells me to use "publicationId".
Is this the same as the sales channel?
I'm a little bit confused by all these terms.
EOL
So I believe the mutation to be used is this one publishablePublishToCurrentChannel.
From there, I am using the GraphiQL application inside the Shopify admin section.
Yet I receive an error stating:
"message": "PublishablePublishToCurrentChannel access denied"
Any idea what could be going on?
Below is the mutation, then the variable, then the response from the API.
Any help is greatly appreciated.
mutation publishablePublishToCurrentChannel($id: ID!) { publishablePublishToCurrentChannel(id: $id) { publishable { availablePublicationCount publicationCount publishedOnCurrentPublication } shop { id } userErrors { field message } } }
Variable (used in GraphiQL application isnde Shopify admin):
{ "id": "gid://shopify/Product/4944224878730" }
And finally, the response stating that access denied:
{ "data": { "publishablePublishToCurrentChannel": null }, "errors": [ { "message": "PublishablePublishToCurrentChannel access denied", "locations": [ { "line": 2, "column": 3 } ], "path": [ "publishablePublishToCurrentChannel" ] } ], "extensions": { "cost": { "requestedQueryCost": 10, "actualQueryCost": 10, "throttleStatus": { "maximumAvailable": 1000, "currentlyAvailable": 990, "restoreRate": 50 } } } }
So... this is going to sound insane, yet the best solution at the moment is:
Create manually a product from within the Shopify administration page.
Set this product inside the Sales Channel you want.
Then, via the GraphQL API, duplicate this product.
Once the product is duplicated, once again make yet another api call to set all the details about the item as you want.
Bananas.
It's crazy the new way isn't publicly available for use after all this time.
I think the easiest solution is to set
'published: true,'
productCreate(input: { title: "Green Tea Ginger Twist", productType: "test", published: true }
The problem with "published: true" is that it only publishes for "online store" which is usually not the only intent
Of course it's a problem. I'd be embarrassed if I was shopify.
But OP only mentioned adding to online. This post is what came up first when I was searching to do the same thing yesterday. It took some effort to figure this disaster out.
Yes agreed the shopify api is simply retarded and a complete joke. This makes storefront completely unusable for me.
Fun fact: Shopify support can enable more APIs in the backend for your app. They did it for mine and now I have full control over publications.
you just need to open a case and ask (and hopefully get the right person)
I have meet same problem and found this topic.
But when I contact Shopify support, they told me this operation is only for Shopify Plus merchant.
To create a product while let it cannot be access by any channel, how Shopify think about it.
Remove an existing function, and then collect money from the user before adding this function back.
Shopify focuses on grabbing money from customers, not on win-win cooperation.
Let us plan to migrate another platform.
User | RANK |
---|---|
8 | |
7 | |
3 | |
3 | |
3 |
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By