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.

Replies 3 (3)
bdeaw
Excursionist
18 0 12

I’d like to know this as well. 

PaulNewton
Shopify Partner
3467 231 677

@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
            }
          }
        }
      }
    }
  }
}

 

 

What important thing did you learn this Black Friday?


Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org

Problem Solved? ✔Accept and Like solutions to help future merchants

Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
HunkyBill
Shopify Expert
4615 54 531

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