A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello everyone, I'm looking for a way to associate a company location with a price catalog using the GraphQL API. I haven't found any information on this topic. Can you help me? Thanks in advance.
Solved! Go to the solution
This is an accepted solution.
Hey @Ggarret , you can create and associate a catalog with a company location by passing the company location ID in the context field of the catalogCreate or catalogUpdate mutation.
- https://shopify.dev/docs/apps/b2b/getting-started#step-2-create-a-b2b-catalog
Once you have that, you can assign a price list to a catalog. https://shopify.dev/docs/apps/b2b/catalogs#step-1-associate-a-price-list-with-the-catalog
Hope that helps,
- Kyle G.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hey @Ggarret , you can create and associate a catalog with a company location by passing the company location ID in the context field of the catalogCreate or catalogUpdate mutation.
- https://shopify.dev/docs/apps/b2b/getting-started#step-2-create-a-b2b-catalog
Once you have that, you can assign a price list to a catalog. https://shopify.dev/docs/apps/b2b/catalogs#step-1-associate-a-price-list-with-the-catalog
Hope that helps,
- Kyle G.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
If you want to add individual locations to a catalog you might want to look at the catalogContextUpdate mutation:
https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/catalogContextUpdate
If you just pass in one location ID to the catalogUpdate mutation you're going to remove it from other locations it was assigned to.
This is a great call out. What support neglects to mention in this case is that assigning the catalog to a company location (or rather adding the location to the catalog) is a SET when using the catalogCreate and catalogUpdate along with the catalogContextUpdate mutations. Meaning you have to provide the entire list of location ids when calling that endpoint. So if you intend to append a location to a catalog, you must query the current list first and send it all back up. But watch out, as you can only send a list of 250 or less...
In our case, we needed to add a catalog to many companies, well over 250 locations. Unfortunately there is no way through the UI or through the APIs to do this it seems. Hopefully bulk operations will be available to us someday.
We were able to work around this by using Flow, which can iterate a location query result and add the catalog one by one. You have to finesse your way through this as it also has a query limit, of 100.