Development discussions around Shopify APIs
I'm coming across some unexpected behavior with the 2019-07 graphql storefront api. The docs state that a product's onlineStoreUrl will be null if the product is not published on the online store. My store has two sales channels, the app I am developing as well as the online store, even when products are published for both channels, products are still returned with a null onlineStoreUrl.
Here is my query:
```
curl -X POST \
"https://quiq-convocom-demo-1.myshopify.com/api/2019-07/graphql.json" \
-H "Content-Type: application/graphql" \
-H "X-Shopify-Storefront-Access-Token: <...>" \
-d '
{
productByHandle(handle: "test-product") {
id
handle
onlineStoreUrl
}
}
'
```
And here is what is returned:
```
{
"data": {
"productByHandle": {
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIzMTUxNzU3ODg2NDA=",
"handle": "test-product",
"onlineStoreUrl": null
}
}
}
```
I have other test stores setup in what I think is the same way, these stores return a valid onlineStoreUrl. For reference the store I am having trouble with is: `https://quiq-convocom-demo-1.myshopify.com/` and the store that is working as I expect `https://standalone1-demo.myshopify.com`.
Happy to provide any additional details as well.
Thanks,
Nick
Solved! Go to the solution
This is an accepted solution.
Hi Nick,
You are correct that the `onlineStoreUrl` will be `null` if a product is not published to the online store. It is important to note as well that if your store is password protected (meaning in the settings of your stores Shopify admin dashboard, you have the password page enabled) `onlineStoreURL` will also be returned as null.
This is something that is currently not clearly noted documentation and so we will work on making this more clear as necessary.
Cheers
This is an accepted solution.
Hi Nick,
You are correct that the `onlineStoreUrl` will be `null` if a product is not published to the online store. It is important to note as well that if your store is password protected (meaning in the settings of your stores Shopify admin dashboard, you have the password page enabled) `onlineStoreURL` will also be returned as null.
This is something that is currently not clearly noted documentation and so we will work on making this more clear as necessary.
Cheers
How are we supposed to create partner apps when we can't unpassword protect the app to get the onlineStoreUrl? Is there something I'm missing on setup, or a way around this so I can test that onlineStoreUrl works?
For anyone just finding this now, you can dynamically build the product URL from the `handle` field on the Product object.
"https://{organization.shopify_storefront_slug}.myshopify.com/products/{product.get('handle')}"
When `onlineStoreUrl` is `null` we fallback to using this as the product url.
Hey Sd_, are there any plans of returning the actual URL instead of null for development stores? Since we can't remove the password of a dev store, it's impossible to test this feature without manually building the URL, which makes using this field pointless.
User | RANK |
---|---|
8 | |
6 | |
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