How to get product URL by specific store view in Magento 2?

Magento supports multi-website feature and each website support multi-store view to display store-based eCommerce site to visitors.

If a website has multiple store views and wants to set different URLs for the product by store view level,
you can do it in Magento by just setting the URL based on the store view. Continue reading “How to get product URL by specific store view in Magento 2?”

How to Get Cross Sell Product GraphQL Query Magento 2?

Cross-Sell Product GraphQL Query in Magento 2 to get all the cross-sell items as an output with GraphQL response.

You can fetch the Cross-sell Product from the Product GraphQL Query by applying the product SKU as a filter name.

Before going with the current article, Check full details of Product Query, Brief details of Product Query GraphQL in Magento.

Cross-Sell Product GraphQL Query Magento 2 Payload,

{
  products(filter: { sku: { eq: "24-MB01" } }) {
    items {
      id
      name
      crosssell_products {
        id
        sku
        stock_status
        short_description {
          html
        }
        url_key
        name
        special_price
        price_range {
          minimum_price {
            final_price {
              value
              currency
            }
          }
          maximum_price {
            final_price {
              value
              currency
            }
          }
        }
      }
    }
  }
}

crosssell_products{} field used to retrieve cross-sell items of the product. You can set any field to retrieve as output from the Product Query.

Output for the Magento Sample Data,

{
  "data": {
    "products": {
      "items": [
        {
          "id": 1,
          "name": "Joust Duffle Bag",
          "crosssell_products": [
            {
              "id": 20,
              "sku": "24-UG01",
              "stock_status": "IN_STOCK",
              "short_description": {
                "html": ""
              },
              "url_key": "quest-lumaflex-trade-band",
              "name": "Quest Lumaflex™ Band",
              "special_price": null,
              "price_range": {
                "minimum_price": {
                  "final_price": {
                    "value": 19,
                    "currency": "USD"
                  }
                },
                "maximum_price": {
                  "final_price": {
                    "value": 19,
                    "currency": "USD"
                  }
                }
              }
            },
            {
              "id": 32,
              "sku": "24-WG083-blue",
              "stock_status": "IN_STOCK",
              "short_description": {
                "html": ""
              },
              "url_key": "sprite-stasis-ball-75-cm-blue",
              "name": "Sprite Stasis Ball 75 cm",
              "special_price": null,
              "price_range": {
                "minimum_price": {
                  "final_price": {
                    "value": 32,
                    "currency": "USD"
                  }
                },
                "maximum_price": {
                  "final_price": {
                    "value": 32,
                    "currency": "USD"
                  }
                }
              }
            },
            {
              "id": 34,
              "sku": "24-WG086",
              "stock_status": "IN_STOCK",
              "short_description": {
                "html": ""
              },
              "url_key": "sprite-yoga-strap-8-foot",
              "name": "Sprite Yoga Strap 8 foot",
              "special_price": null,
              "price_range": {
                "minimum_price": {
                  "final_price": {
                    "value": 17,
                    "currency": "USD"
                  }
                },
                "maximum_price": {
                  "final_price": {
                    "value": 17,
                    "currency": "USD"
                  }
                }
              }
            },
            {
              "id": 51,
              "sku": "24-WG085_Group",
              "stock_status": "IN_STOCK",
              "short_description": {
                "html": ""
              },
              "url_key": "set-of-sprite-yoga-straps",
              "name": "Set of Sprite Yoga Straps",
              "special_price": null,
              "price_range": {
                "minimum_price": {
                  "final_price": {
                    "value": 14,
                    "currency": "USD"
                  }
                },
                "maximum_price": {
                  "final_price": {
                    "value": 14,
                    "currency": "USD"
                  }
                }
              }
            }
          ]
        }
      ]
    }
  }
}

You can add/remove the field based on your requirement in the product Query. This is the demonstration purpose only.

You can also interested to read GraphQL Query,

  1. Get Related Product GraphQL Query in Magento 2.
  2. Get Upsell Product GraphQL Query Magento 2.

How to Get Upsell Product GraphQL Query Magento 2?

Upsell Product GraphQl query in Magento 2 to retrieve all the upsell items from the given product.

If any product has assigned upsell products from the admin panel and wants to fetch all the upsell items using the GraphQL query, the given post is useful for you.

Detail Description of Product Query GraphQL Magento Check this article first to get a clear idea of Product Query. Continue reading “How to Get Upsell Product GraphQL Query Magento 2?”