# StoreFrontApiで商品検索時にavailableのFilterをかけても、「在庫あり」と「在庫切れ」の商品数が合わない

**URL:** <https://community.shopify.com/t/storefrontapi-available-filter/263983>\
**Category:** 技術的なQ＆A\
**Created:** [October 31, 2023, 1:55am UTC](https://community.shopify.com/t/storefrontapi-available-filter/263983 "2023-10-31T01:55:24Z")\
**Posts on this page:** 2\
**Page:** 1

## AI-generated summary

StoreFront APIで商品検索時に`available`フィルターを使用した際、フィルター結果の商品数が管理画面の実際の在庫状況と一致しない問題が報告されています。

**具体的な不一致:**
- APIレスポンスの`filters.count`では「在庫あり=2」「在庫なし=12」と表示
- 管理画面のコレクションでは、アーカイブを除いて「在庫切れ=10」のはず
- 数値に2件の差異が発生

**考えられる原因:**
投稿者は、`available=false`が単純な「在庫なし」ではなく、アーカイブ以外の商品数を指している可能性を疑問視しています。Shopifyのバグの可能性も検討中です。

**解決状況:**
Shopifyコミュニティの別スレッド(在庫があるのに在庫切れと表示される問題)へのリンクが提示されており、解決済みとマークされていますが、具体的な解決方法の詳細は本スレッドには記載されていません。

<div class="post-metadata">

**Author:** ![akkyyyy](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@akkyyyy](https://community.shopify.com/u/akkyyyy)\
**Post date:** [October 31, 2023, 1:55am UTC](https://community.shopify.com/t/storefrontapi-available-filter/263983/1 "2023-10-31T01:55:24Z")

</div>

商品にフィルターをかけて検索しているのですが、「在庫あり」と「在庫なし」の商品数が合わないです。

下記のレスポンスのfilters.countで「在庫あり＝2」と「在庫なし=12」となってますが、管理画面のコレクションに紐づく商品数を見てみると、アーカイブを除いて、「在庫切れ=10」になるはずです。

これはshopifyのバグですか？

もしくはavailable＝falseが在庫なしではなく、アーカイブ以外の商品数のことを指しますか？

ご存知の方がいましたら、ご教授願います。

【クエリ】

```auto
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
            }
        }
    }
}
}

```

【レスポンス】

```auto
				"filters": [
					{
						"values": [
							{
								"count": 2,
								"id": "filter.v.availability.1",
								"input": "{\"available\":true}",
								"label": "在庫あり"
							},
							{
								"count": 12,
								"id": "filter.v.availability.0",
								"input": "{\"available\":false}",
								"label": "在庫切れ"
							}
						]
					}
				]

```

---

<div class="post-metadata">

**Author:** ![akkyyyy](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@akkyyyy](https://community.shopify.com/u/akkyyyy)\
**Post date:** [November 15, 2023, 6:31am UTC](https://community.shopify.com/t/storefrontapi-available-filter/263983/2 "2023-11-15T06:31:42Z")

</div>

This is an accepted solution.

[https://community.shopify.com/c/technical-q-a/i-have-inventory-but-it-s-showing-as-out-of-stock/m-p/…](https://community.shopify.com/post/2310721)
