Solved

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

rafaelmarques
Tourist
10 0 2

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
1323 218 458

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
1323 218 458

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 2

Worked perfectly. Thanks Kyle