Magento 2 How to get cross-sell products in GraphQL

If you had ever noticed that cross-sell products are always found in the shopping cart, now in this article, we will show you how to get cross-sell products.

We need to perform a products query for cross-sell products. The following query returns information about cross-sell products.


{ 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 crosssell_products { id name sku } } } }


{ "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", "crosssell_products": [ { "id": 21, "name": "Sprite Foam Yoga Brick", "sku": "24-WG084" }, { "id": 23, "name": "Harmony Lumaflex™ Strength Band Kit ", "sku": "24-UG03" }, { "id": 33, "name": "Sprite Yoga Strap 6 foot", "sku": "24-WG085" }, { "id": 35, "name": "Sprite Yoga Strap 10 foot", "sku": "24-WG087" } ] } ] } } }

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
Chrome Extension
Copyright © 2024 All rights reserved.
Ads OFF toggle_off