productRelationSuggestions
Requires permission products:product:read.
Returns up to 20 upsell, cross-sell or substitute suggestions for a set of products, for example a customer's purchase history. Each suggested product appears once, deleted products are left out, and the list is empty when nothing is set up. Needs the products read permission.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
query ProductRelationSuggestions($productIds: [String!]!) {
productRelationSuggestions(productIds: $productIds) {
id
type
note
relatedProduct {
id
name
imageUrl
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "query ProductRelationSuggestions($productIds: [String!]!) {\n productRelationSuggestions(productIds: $productIds) {\n id\n type\n note\n relatedProduct {\n id\n name\n imageUrl\n }\n }\n}",
"variables": {
"productIds": [
"string"
]
}
}
EOF
Variables:
{
"productIds": [
"string"
]
}
Response:
{
"data": {
"productRelationSuggestions": [
{
"id": "id",
"type": "CROSS_SELL",
"note": "string",
"relatedProduct": {
"id": "id",
"name": "string",
"imageUrl": "string"
}
}
]
}
}
productRelationSuggestions(
productIds: [String!]!
): [ProductRelationSuggestion!]!
Arguments
productRelationSuggestions.productIds ● [String!]! non-null scalar
The IDs of the source products to find suggestions for.
Type
ProductRelationSuggestion object
A suggested related product.