Another day another struggle.
Needing a list of ALL vendors of the shop. After searching for quite a while, came up with these solutions:
- Iterating through all products. Obviously, less effective.
{
products(first: 250, after: "#{cursor}") {
edges {
cursor
node {
id
vendor
}
}
pageInfo {
hasNextPage
}
}
}
- Getting vendors through Shopâs productVendors object. Has limit of 250 records though âfirstâ parameter and no way to iterate, thus absolutely useless when we need to get them all.
Code example: https://community.shopify.com/c/shopify-apis-and-sdks/json-list-of-vendors-api/m-p/600737/highlight/true#M40690
query productVendors {
shop {
productVendors(first: 200) {
edges {
node
}
}
}
}
There is a similar problem with product tags as mentioned in this thread. There even Shopify official staff admitted the problem but years passed, the problem is still there.
- Creating a template accessible via store custom page with content similar to:
{% layout none %}{{shop.vendors|json}}
Code example from the same thread as above.
There is even a blog post that describes how to use similar method to get all the vendors and product tags as itâs impossible to do with API. His code for the vendors seems to be more complicate from the quoted above.
Well this solution likely works, and in one of the threads above itâs been reported as the year-proof solution, but there is a problem in my case. The store is password protected so to access this page from within my app, I would need to write a separate authentication code just for this task. So I thought I could query the page through admin API. And I actually could, but pageâs body_html is empty, so it returns an uninterpreted page content and I havenât figured out how can you request the actual page content though the API.
- As found on this stackoverflow thread you can also get this straight without the need to create any page templates by querying
https://{{ shop_doamin }}/admin/products/vendors.json
This is probably something that the web based Shopify app uses by itself and is not intended to be used by an external API which again would require another layer of authorization to code.
So how could I query all the vendors with API or access the contents of the generated page which uses a custom template as in case 3. ?
