Skip to main content

Display cross-sell and upsell products

Fetch related products and clusters linked to the current product for a "You might also need" section.

Query

query GetCrossUpsell($productId: Int!, $language: String) {
product(productId: $productId) {
crossupsellsFrom(input: { offset: 12, page: 1 }) {
items {
type
productTo {
... on Product {
productId
names(language: $language) {
value
}
price {
gross
net
}
media {
images(search: { sort: ASC, offset: 1 }) {
items {
imageVariants(
input: {
transformations: {
name: "thumb"
transformation: {
width: 200
height: 200
fit: BOUNDS
format: WEBP
}
}
}
) {
url
}
}
}
}
}
... on Cluster {
clusterId
names(language: $language) {
value
}
defaultProduct {
productId
price {
gross
net
}
}
}
}
}
itemsFound
}
}
}

Variables

{
"productId": 123,
"language": "EN"
}

Response

{
"data": {
"product": {
"crossupsellsFrom": {
"items": [
{
"type": "RELATED",
"productTo": {
"productId": 26,
"names": [{ "value": "Dovre Rock350 TB" }],
"price": { "gross": 2275.21, "net": 2753.00 }
}
},
{
"type": "ACCESSORIES",
"productTo": {
"productId": 31,
"names": [{ "value": "Dovre Saga 101 heat shield left" }],
"price": { "gross": 70.00, "net": 84.70 }
}
},
{
"type": "PARTS",
"productTo": {
"productId": 28,
"names": [{ "value": "Dovre 425CB fire bed" }],
"price": { "gross": 172.44, "net": 208.65 }
}
}
],
"itemsFound": 12
}
}
}
}

How it works

Each item has a type field describing the relationship: RELATED, ACCESSORIES, PARTS, or OPTIONS. Use crossupsellsFrom to get products linked from the current product, or crossupsellsTo for the reverse direction. The productTo field is a union — it can be a Product or Cluster, so use inline fragments to access type-specific fields.

See also