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 6 (6)
bdeaw
Shopify Partner
30 0 20

I’d like to know this as well. 

PaulNewton
Shopify Partner
4205 303 899

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

 

 

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

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
4762 54 548

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
bdeaw
Shopify Partner
30 0 20

I'd like to know how to find item that are ONLY in the All collection? 

HunkyBill
Shopify Expert
4762 54 548

That is the same thing as asking the questions:

- are there any merchant created collections? If the answer is no, all your products are in all.

- if there are collections, are there any products in any of these collections? If yes, remove those from your count of all

 

Simply amazing that this can be such a simple script that takes mere minutes to write and perhaps just seconds to execute.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Brennon-RS
New Member
1 0 0

Any chance we can connect on how this is accomplished?