productSearch query
The Catalog Service for Adobe Commerce productSearch
query can use Live Search to return details about the SKUs specified as input. Although this query is functionally similar to the Live Search productSearch
query, Live Search returns a productView
object. See the productSearch
query topic for reference information.
Syntax
Copied to your clipboardproductSearch(phrase: String!page_size: Int = 20current_page: Int = 1filter: [SearchClauseInput!]sort: [ProductSearchSortInput!]): ProductSearchResponse!
Endpoints
- Testing:
https://catalog-service-sandbox.adobe.io/graphql
- Production:
https://catalog-service.adobe.io/graphql
Required headers
You must specify the following HTTP headers to run this query.
Header | Description |
---|---|
Magento-Customer-Group | This value is available in the customer_group_data_exporter database table. |
Magento-Environment-Id | This value is displayed at System > Commerce Services Connector > SaaS Identifier > Data Space ID or can be obtained by running the bin/magento config:show services_connector/services_id/environment_id command. |
Magento-Store-Code | The code assigned to the store associated with the active store view. For example, main_website_store . |
Magento-Store-View-Code | The code assigned to the active store view. For example, default . |
Magento-Website-Code | The code assigned to the website associated with the active store view. For example, base . |
X-Api-Key | A unique key that is generated during the onboarding process. |
Example usage
In the following example, the query returns information on the same products as the Live Search productSearch
items list example. However, it has been constructed to return item information inside the Catalog Service productView
object instead of the core product
object. Note that the pricing information varies, depending on the product type. For the sake of brevity, facet information is not shown.
Request:
Copied to your clipboard{productSearch(phrase: "bag"sort: [{attribute: "price"direction: DESC }]page_size: 9) {page_info {current_pagepage_sizetotal_pages}items {productView {namesku... on SimpleProductView {price {final {amount {valuecurrency}}regular {amount {valuecurrency}}}}... on ComplexProductView {options {idtitlerequiredvalues {idtitle}}priceRange {maximum {final {amount {valuecurrency}}regular {amount {valuecurrency}}}minimum {final {amount {valuecurrency}}regular {amount {valuecurrency}}}}}}}}}
Response:
Copied to your clipboard{"data": {"productSearch": {"page_info": {"current_page": 1,"page_size": 9,"total_pages": 3},"items": [{"productView": {"name": "Impulse Duffle","sku": "24-UB02","price": {"final": {"amount": {"value": 74,"currency": "USD"}},"regular": {"amount": {"value": 74,"currency": "USD"}}}}},{"productView": {"name": "Fusion Backpack 567890","sku": "24-MB02","price": {"final": {"amount": {"value": 59,"currency": "USD"}},"regular": {"amount": {"value": 59,"currency": "USD"}}}}},{"productView": {"name": "Rival Field Messenger","sku": "24-MB06","price": {"final": {"amount": {"value": 45,"currency": "USD"}},"regular": {"amount": {"value": 45,"currency": "USD"}}}}},{"productView": {"name": "Push It Messenger Bag","sku": "24-WB04","price": {"final": {"amount": {"value": 45,"currency": "USD"}},"regular": {"amount": {"value": 45,"currency": "USD"}}}}},{"productView": {"name": "Overnight Duffle","sku": "24-WB07","price": {"final": {"amount": {"value": 45,"currency": "USD"}},"regular": {"amount": {"value": 45,"currency": "USD"}}}}},{"productView": {"name": "Wayfarer Messenger Bag 987","sku": "24-MB05","price": {"final": {"amount": {"value": 44,"currency": "USD"}},"regular": {"amount": {"value": 44,"currency": "USD"}}}}},{"productView": {"name": "Driven Backpack","sku": "24-WB03","price": {"final": {"amount": {"value": 36,"currency": "USD"}},"regular": {"amount": {"value": 36,"currency": "USD"}}}}}]}}}