Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Company and catalog graphql api

Solved

Company and catalog graphql api

Ggarret
Visitor
3 0 0

 

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.

 

 

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 239 534

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

View solution in original post

Replies 3 (3)

ShopifyDevSup
Shopify Staff
1453 239 534

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

Kalen_Jordan
Shopify Partner
803 39 147

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.

mattcampbellbb
Shopify Partner
1 0 1

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.


Screenshot from 2024-10-17 13-42-09.png