0

I'm confused. I'm querying categories and tried to add id field but it says it's deprecated and suggested to use uid instead. But to get products we need category id, when I tried to use uid it doesn't work. enter image description here

enter image description here

Anyone any ideas?

2 Answers 2

1

You can still filter your category/product request by their entity ID. It's advised you now use the uid field in the category response. Docs: https://developer.adobe.com/commerce/webapi/graphql/schema/products/queries/categories/#example-usage

You should be able to filter your product query by category_uid also, maybe you need to change uid to category_uid on your product query filter?

This is explained further here in docs: https://developer.adobe.com/commerce/webapi/graphql/schema/products/queries/products/#filter-attribute.

1
  • Thanks @Liam, you're right I've missed that category_uid is the one! Mar 3 at 14:01
0

If my understanding is right then you want to get the products from the category.

Graphql API Request to get Products from category.

    {
      categoryList(filters: {ids: {eq: "10"}}) {
        products {
          total_count
          items{
            id
            sku
            name
            url_key
            stock_status
            new
            image{
              url
              label
              position
            }
            small_image{
              url
              label
              position
            }
            thumbnail{
              url
              label
              position
            }
            short_description{
              html
            }
            description{
              html
            }
            price_range{
              minimum_price{
                regular_price{
                  value
                  currency
                }
                final_price{
                  value
                  currency
                }
              }
              maximum_price{
                regular_price{
                  value
                  currency
                }
                final_price{
                  value
                  currency
                }
              }
            }
            new_from_date
            new_to_date
            special_price
            special_from_date
            special_to_date
            gift_message_available
            country_of_manufacture
            price_tiers{
              quantity
              final_price{
                value
                currency
              }
              discount{
                amount_off
                percent_off
              }
            }
          }
          page_info {
            current_page
            page_size
          }
        }
      }
    }

Graphql API Response :

Graphql API Response : 

{
  "data": {
    "categoryList": [
      {
        "products": {
          "total_count": 6,
          "items": [
            {
              "id": 50,
              "sku": "240-LV09",
              "name": "Luma Yoga For Life",
              "url_key": "luma-yoga-for-life",
              "stock_status": "IN_STOCK",
              "new": null,
              "image": {
                "url": "https://magento2-b2b.magebit.com/media/catalog/product/cache/69fa647f4cb4608314f8918f61eb211f/l/t/lt06.jpg",
                "label": "Luma Yoga For Life",
                "position": null
              },
              "small_image": {
                "url": "https://magento2-b2b.magebit.com/media/catalog/product/cache/69fa647f4cb4608314f8918f61eb211f/l/t/lt06.jpg",
                "label": "Luma Yoga For Life",
                "position": null
              },
              "thumbnail": {
                "url": "https://magento2-b2b.magebit.com/media/catalog/product/cache/69fa647f4cb4608314f8918f61eb211f/l/t/lt06.jpg",
                "label": "Luma Yoga For Life",
                "position": null
              },
              "short_description": {
                "html": "<p>\nLuma founder Erin Renny on yoga and longevity: \"willing to breathe and learn with me.\"\n</p>"
              },
              "description": {
                "html": "<ul><li>Increase strength + flexibility for her audience.</p>"
              },
              "price_range": {
                "minimum_price": {
                  "regular_price": {
                    "value": 0,
                    "currency": "USD"
                  },
                  "final_price": {
                    "value": 0,
                    "currency": "USD"
                  }
                },
                "maximum_price": {
                  "regular_price": {
                    "value": 0,
                    "currency": "USD"
                  },
                  "final_price": {
                    "value": 0,
                    "currency": "USD"
                  }
                }
              },
              "new_from_date": null,
              "new_to_date": null,
              "special_price": null,
              "special_from_date": null,
              "special_to_date": null,
              "gift_message_available": null,
              "country_of_manufacture": null,
              "price_tiers": []
            }
          ],
          "page_info": {
            "current_page": 1,
            "page_size": 20
          }
        }
      }
    ]
  }
}

It's working fine, You can see the below screenshot.

For more details you can refer this link.

If you want to know the default available Graphql API List then you can check here.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.