Fråga Adobe Commerce Optimizer

Lär dig hur du hämtar data med GraphQL i en Adobe Commerce Optimizer-instans.

Vem är den här videon till?

  • Commerce Solution Architect och utvecklare

Videoinnehåll

  • Fråga data med GraphQL
  • Använda jq för att göra JSON enklare att läsa

Kodexempel

Se till att utbyta värden som {{insert-your-graphql-endpoint-url}}, {{insert-your-ac-view-id}} och {{your-search-query-string}} med de värden som behövs i din fråga.

Enkel exempelfråga

curl '{{insert-your-graphql-endpoint-url}}' \
-H 'Content-Type: application/json' \
-H 'AC-View-ID: {{insert-your-ac-view-id}}' \
-d '{"query": "query ProductSearch($search: String!) { productSearch( phrase: $search, page_size: 10, current_page: 2) { items { productView { sku name description shortDescription images { url } ... on SimpleProductView { attributes { label name value } price { regular { amount { value currency } } roles } } } } } }", "variables": { "search": "{{your-search-query-string}}"}}'

Grundläggande provfråga med jq för att göra en vacker utskrift

curl '{{insert-your-graphql-endpoint-url}}' \
-H 'Content-Type: application/json' \
-H 'AC-View-ID: {{insert-your-ac-view-id}}' \
-d '{"query": "query ProductSearch($search: String!) { productSearch( phrase: $search, page_size: 10, current_page: 2) { items { productView { sku name description shortDescription images { url } ... on SimpleProductView { attributes { label name value } price { regular { amount { value currency } } roles } } } } } }", "variables": { "search": "{{your-search-query-string}}"}}' | jq .

Relaterat innehåll

recommendation-more-help
3a5f7e19-f383-4af8-8983-d01154c1402f