Out now! Check out the Poll results: Do you have a Shopify store?
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.

Retrieve the B2B catalogs assigned to a product using the Admin Grpahql API

Solved

Retrieve the B2B catalogs assigned to a product using the Admin Grpahql API

rafaelmarques
Tourist
10 0 3

Currently I can't seem to find a field responsible for retrieving the B2B catalogs whitin the product data in the graphql admin api.

 

This is the Graphql query I'm using. 

https://shopify.dev/docs/api/admin-graphql/unstable/objects/Product

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 522

This is an accepted solution.

Hey @rafaelmarques , that's a great question. 

When you're looking at the product resource, the B2B catalogues that the products are published on are going to be available in the publications. 

An example query if you're looking to see if a product is available to a specific company, you can use publishedInContext 

query Product {
   product(id: "gid://shopify/Product/[ID]") {
       publishedInContext(
           context: { companyLocationId: "gid://shopify/CompanyLocation/[ID]" }
       )
   }
}

You can also use resourcePublicationsV2 to get the specific catalogs.

        resourcePublicationsV2(catalogType: COMPANY_LOCATION, first: 15) {
           nodes {
               publication {
                   id
                   catalog {
                       id
                   }
               }
           }
       }

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 2 (2)

ShopifyDevSup
Shopify Staff
1453 238 522

This is an accepted solution.

Hey @rafaelmarques , that's a great question. 

When you're looking at the product resource, the B2B catalogues that the products are published on are going to be available in the publications. 

An example query if you're looking to see if a product is available to a specific company, you can use publishedInContext 

query Product {
   product(id: "gid://shopify/Product/[ID]") {
       publishedInContext(
           context: { companyLocationId: "gid://shopify/CompanyLocation/[ID]" }
       )
   }
}

You can also use resourcePublicationsV2 to get the specific catalogs.

        resourcePublicationsV2(catalogType: COMPANY_LOCATION, first: 15) {
           nodes {
               publication {
                   id
                   catalog {
                       id
                   }
               }
           }
       }

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

rafaelmarques
Tourist
10 0 3

Worked perfectly. Thanks Kyle