Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopify App: Product ID not correct #1206

Closed
jaymakes11 opened this issue Apr 29, 2022 · 2 comments
Closed

Shopify App: Product ID not correct #1206

jaymakes11 opened this issue Apr 29, 2022 · 2 comments

Comments

@jaymakes11
Copy link

I'm currently experiencing a good deal of confusion around IDs in Shopify's API.

The one that this plugin returns is a long string of around 48 characters. Example: Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzY1MzcxMjM1Mjg3NTY=.

However, the only ID I can seem to get Shopify's APIs (any of them, the storefront and the admin) to return are either short numeric (e.g. 6586511065140) or longer strings that are essentially gid versions with the same otherwise numeric (e.g. gid://shopify/Product/6586511065140).

In the past, Shopify's admin API was returning the former (the long 48 char version) but something has changed which has broken my site (incredibly frustrating!).

Is there no way for this plugin to use the shorter numeric or gid version of the ID?

Note that I was using the default product variant option for the plugin but have since switched the just the product option, though this problem existed before I made the change (and I thought that perhaps the change might solve the issue, but it did not).

@andipaetzold
Copy link
Contributor

Hey @jaymakes11,

Shopify introduced a change in its API: https://shopify.dev/api/release-notes/2022-04#non-encoded-object-ids-in-the-graphql-storefront-api
From version 2022-04, their api changed the format of the returned ids. The Shopify Contentful App uses version 2019-10 and therefore still returns the "old" id format.

You can specify the API version via the url. E.g. https://xxx.myshopify.com/api/2019-10/graphql. I assume you don't specify any version and therefore always use the latest version of the api.

@andipaetzold
Copy link
Contributor

Alternatively, you can base64 decode the id stored in Contentful. That way you receive the gid-URI.

Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzY1MzcxMjM1Mjg3NTY= -> gid://shopify/Product/6537123528756

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants