Get collections that contain a specific product ID

Get collections that contain a specific product ID

jgd
Shopify Partner
6 0 1

Collections have a field called hasProduct.

That tells whether the collection includes the specified product

 

https://shopify.dev/api/admin-graphql/2022-01/objects/collection#fields

 

I cant get it working.

 

Any ideas how it could be added to the next request?

 

 

 

 

query ($first: Int, $query: String, $sort_key: CollectionSortKeys) {
    collections (first: $first, query: $query, sortKey: $sort_key) {
        edges {
            node {
                legacyResourceId
                title
                productsCount
                updatedAt
                ruleSet {
                    rules {
                        condition
                    }
                }
            }
        }
        pageInfo {
            hasNextPage
            hasPreviousPage
        }
    }
}

 

 

 

 

Thanks in advance.

Replies 0 (0)