Why is this product query filter not working?

Solved

Why is this product query filter not working?

no_robotocha
Shopify Partner
54 2 11

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
Shopify Staff
2873 312 819

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
Shopify Staff
2873 312 819

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
54 2 11

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
Shopify Staff
2873 312 819

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