How I can publish the product on shopify store using GraphQL. Here is my phpcode in which I am getting empty publisherID due to which it is not publishing. I am creating a public app.
If the store is just setup how to make our product published on addition of product via graphQL.
$publicationId = ‘’;
$pubQuery = ‘{ publications(first: 5) { edges { node { id name } } } }’;
$chPubList = curl_init($graphql_url);
curl_setopt($chPubList, CURLOPT_RETURNTRANSFER, true);
curl_setopt($chPubList, CURLOPT_POSTFIELDS, json_encode([‘query’ => $pubQuery]));
curl_setopt($chPubList, CURLOPT_HTTPHEADER, [“Content-Type: application/json”, “X-Shopify-Access-Token: $access_token”]);
$pubListResp = curl_exec($chPubList);
curl_close($chPubList);
$pubListData = json_decode($pubListResp, true);
foreach (($pubListData[‘data’][‘publications’][‘edges’] ?? ) as $edge) {
if ($edge[‘node’][‘name’] === ‘Online Store’) {
$publicationId = $edge[‘node’][‘id’];
break;
}
}
Please help how to fix it and guide. As you cannot ask people to publish each product if the store is new.
1 Like
What does your list of publications look like?
You can also publish products in bulk via Shopify Admin if you want people to publish many products 
Hey @Richard_Mayer
I tested your publications query on my own test store. I was able to find the “Online Store” publication along with several others. To follow up from Jordan’s question above, what exactly are you getting back when you run that query? Are you seeing an empty publications array, or are you getting publications but none named “Online Store”?
I’d recommend testing this in an API client like Postman or GraphiQL to isolate whether it’s a code issue or a store configuration problem. Here’s the exact query to test:
{
publications(first: 10) {
edges {
node {
id
name
}
}
}
}
Also worth double-checking that the Online Store sales channel is actually enabled on your test store. You can verify this in your Shopify admin under Settings → Apps And Sales channels.
Let me know how that goes!
Hey Richard,
Are you still experiencing this issue, or can I mark this as solved?
Thanks everyone for your reply and support. You can close the ticket.