Magento 2 How to get upsell products in GraphQL

We all know that what is upsell products and an item offered as an upsell might be of higher quality, more popular, or have a better profit margin.

We need to perform a products query for upsell products. Please check below and follow query which returns upsell products information.

Request

saveCopyzoom_out_map
{ products(filter: { sku: { eq: "24-WB03" } }) { total_count items { id name sku url_key stock_status new_from_date new_to_date special_price special_from_date special_to_date __typename upsell_products { id name sku } } } }

Response

saveCopyzoom_out_map
{ "data": { "products": { "total_count": 1, "items": [ { "id": 12, "name": "Driven Backpack", "sku": "24-WB03", "url_key": "driven-backpack", "stock_status": "IN_STOCK", "new_from_date": null, "new_to_date": null, "special_price": null, "special_from_date": null, "special_to_date": null, "__typename": "SimpleProduct", "upsell_products": [ { "id": 3, "name": "Crown Summit Backpack", "sku": "24-MB03" }, { "id": 4, "name": "Wayfarer Messenger Bag", "sku": "24-MB05" }, { "id": 5, "name": "Rival Field Messenger", "sku": "24-MB06" }, { "id": 6, "name": "Fusion Backpack", "sku": "24-MB02" }, { "id": 7, "name": "Impulse Duffle", "sku": "24-UB02" }, { "id": 13, "name": "Overnight Duffle", "sku": "24-WB07" }, { "id": 14, "name": "Push It Messenger Bag", "sku": "24-WB04" } ] } ] } } }

That's it!!

If you are looking for more GraphQL solutions then check out our another article which is List of GraphQL Queries and Mutations for Magento 2.

I hope this article helps you to find what you were looking for.

Bookmark it for your future reference. Do comment below if you have any other questions on that.

P.S. Do share this article with your team.




Recent Articles
Tags
Newsletter
Chrome Extension
Copyright © 2024 devhooks.in All rights reserved.
Ads OFF toggle_off
wifi_off