OCAPI フィルタリング 23.1

リソースタイプと関係タイプを指定 (URL スキーマを参照) した後、フィルターパラメーターを指定して、結果セットのリソースインスタンスの数をさらに減らすことができます。フィルターパラメーターは、各 resource_typerelationship_type の組み合わせに応じて異なります。次の例では、最初のフィルターパラメーター typecross_sell の値を指定し、これにより、タイプが cross_sell と等しくないすべてのスソースインスタンスが結果セットから除外されます。2 つ目のフィルターパラメーター direction で値 out を指定し、方向が異なるすべてのリソースインスタンスが除外されます。

1REQUEST:
2GET /dw/shop/v23_1/products/123/links?type=cross_sell&direction=out HTTP/1.1
3Host: example.com
4Accept: application/json
5
6RESPONSE:
7HTTP/1.1 200 OK
8Content-Length: 351
9Content-Type: application/json; charset=UTF-8
10
11{
12  "_v" : "23.1",
13  ...
14  "product_links":
15  [{
16    "source_product_id":"123",
17    "source_product_link":"http://example.com/dw/shop/v23_1/product/123",
18    "target_product_id":"456",
19    "target_product_link":"http://example.com/dw/shop/v23_1/product/456",
20    "type":"cross_sell",
21    "direction":"out"
22  },
23  {
24    "source_product_id":"123",
25    "source_product_link":"http://example.com/dw/shop/v23_1/product/123",
26    "target_product_id":"789",
27    "target_product_link":"http://example.com/dw/shop/v23_1/product/789",
28    "type":"cross_sell",
29    "direction":"out"
30  }]

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!