Counts For "In Stock" And "Out Of Stock" Products Do Not Match With The "Available" Filter

Solved

Counts For "In Stock" And "Out Of Stock" Products Do Not Match With The "Available" Filter

akkyyyy
Shopify Partner
14 4 4

I'm filtering products, but the counts for "in stock" and "out of stock" don't match. In the response, filters.count shows "in stock = 2" and "out of stock = 12," but when I check the number of products associated with the collection in the display, "out of stock" should be 10. Is this a Shopify bug? Or does available=false refer to the number of products, excluding archived ones, rather than out of stock? If anyone has information, please share your knowledge.

 

<query>

query getProductsByCollection(
    \$limit: Int = 10
    \$afterCursor: String
    \$sortKey: ProductCollectionSortKeys
    \$reverse: Boolean
  ) {
    collection(id: "gid://shopify/Collection/460299993388") {
      products(
        first: \$limit
        sortKey: \$sortKey
        reverse: \$reverse
        after: \$afterCursor
        filters:[
            {
                available : true
            },
        ]
      ) {
        edges {
          node {
            id
            title
            variants(first: 1) {
                edges {
                  node {
                    id
                    title
                    availableForSale
                  }
                }
            }
        }
        }
        filters {
            values {
                count
                id
                input
                label
            }
        }
    }
}
}

<responce>

"filters": [
					{
						"values": [
							{
								"count": 2,
								"id": "filter.v.availability.1",
								"input": "{\"available\":true}",
								"label": "in stock"
							},
							{
								"count": 12,
								"id": "filter.v.availability.0",
								"input": "{\"available\":false}",
								"label": "out of stock"
							}
						]
					}
				]

 

Accepted Solution (1)
Reply 1 (1)

akkyyyy
Shopify Partner
14 4 4