Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Why is this product query filter not working?

Solved

Why is this product query filter not working?

no_robotocha
Shopify Partner
58 2 20

I've added a query filter to this request to filter for ACTIVE products, yet it does not affect the results which include ARCHIVED as well as ACTIVE etc.

 

Screenshot 2024-07-03 at 15.08.55.png

 

I've tried using ACTIVE and active and some variations but no luck.

 

Can anyone tell me what I'm doing wrong?

 

query GiftFinderData {
  products(first: 10, query:"product_status:active") {
    edges {
      node {
        id
        title
        status
        descriptionHtml
        variants(first: 10) {
          edges {
            node {
              title
              price
              legacyResourceId
            }
          }
        }
      }
    }
  }
}
--
No, Robotocha!
Accepted Solution (1)

Liam
Community Manager
3108 344 911

This is an accepted solution.

It should work with this:

 

query GetActiveProducts {
  products(first: 10, query: "status:active") {
    edges {
      node {
        id
        title
        status
        totalInventory
        priceRangeV2 {
          minVariantPrice {
            amount
            currencyCode
          }
          maxVariantPrice {
            amount
            currencyCode
          }
        }
      }
    }
  }
}

using `query: "status:active"` 

 

I tested it, and archived products are not appearing for me now.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 3 (3)

Liam
Community Manager
3108 344 911

This is an accepted solution.

It should work with this:

 

query GetActiveProducts {
  products(first: 10, query: "status:active") {
    edges {
      node {
        id
        title
        status
        totalInventory
        priceRangeV2 {
          minVariantPrice {
            amount
            currencyCode
          }
          maxVariantPrice {
            amount
            currencyCode
          }
        }
      }
    }
  }
}

using `query: "status:active"` 

 

I tested it, and archived products are not appearing for me now.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

no_robotocha
Shopify Partner
58 2 20

That's it, thank you @Liam - feel like a bit of an idiot missing this but your response has helped me figure out why I got this wrong too and a big part of this has clicked for me so I appreciate it.

--
No, Robotocha!
Liam
Community Manager
3108 344 911

Great to hear! 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog