Getting "orphan" products

NoKidding
New Member
1 0 1

Hello. is there any way using the admin API to get all of the products which do not belong to any collection?

Thanks.

bdeaw
Excursionist
18 0 13

I’d like to know this as well. 

0 Likes
PaulNewton
Shopify Partner
3123 194 575

@NoKidding , @bdeaw 

I dont' think that comparison is available in products query arguments.

You could use bulk operations to get all products with a CollectionConnection in the query then just go through each product 

 

{
  products {
    edges {
      node {
        collections(first: 2) {
          edges {
            node {
              id
            }
          }
        }
      }
    }
  }
}

 

 

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes
HunkyBill
Shopify Expert
4583 50 519

All products belong to the collection "all" so therefore there are zero products that belong to no collections. But if you wanted to do this for another reason:

- download all products using a bulk query

- for each collection, get the products by id, and remove them from your global list you bulk downloaded

once done, you'd only have products in your big list that were not in any collection. This is a very simple exercise to script.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com