1

I am using v2.4 in which in the products query I am getting the Optionid of select attribute instead of attribute option label. Like if i try to get color(select type) then I get value of red instead of label Red

So anybody can help me get the label instead of id

Here is my sample code

query {
 products(search:"test", pageSize: 15, sort: {price: DESC}) {
  total_count
  items {
    name
    sku
    color
    price_range {
      minimum_price {
        regular_price {
          value
          currency
        }
      }
    }
   }
 }
}
1

2 Answers 2

0

You can also find the attribute option label by searching the attribute option ID with https://devdocs.magento.com/guides/v2.4/graphql/queries/custom-attribute-metadata.html

-1

Try this

query {
 products(search:"test", pageSize: 15, sort: {price: DESC}) {
  total_count
  items {
      id
      name
      sku
      __typename
      price_range {
        minimum_price {
          regular_price {
            value
            currency
          }
        }
      }
      ... on ConfigurableProduct {
        configurable_options {
          id
          attribute_id_v2
          use_default
          attribute_code
          values {
            value_index
            label
          }
          product_id
        }
        variants {
          attributes {
            label
            code
            value_index
          }
          product {
            id
            name
            sku
            stock_status
            short_description {
              html
            }
            description {
              html
            }
            image {
              url
              label
            }
            small_image {
              url
              label
            }
            media_gallery {
              url
              label
              ... on ProductVideo {
                video_content {
                  media_type
                  video_provider
                  video_url
                  video_title
                  video_description
                  video_metadata
                }
              }
            }
            price_range {
              minimum_price {
                regular_price {
                  value
                  currency
                }
                final_price {
                  value
                  currency
                }
                discount {
                  amount_off
                  percent_off
                }
              }
            }
          }
        }
      }
    }
 }
}
2
  • How is this supposed to help? The query even doesn't contain the color attribute to fetch Feb 17 at 9:43
  • @VasiliiBurlacu if the product has valid data then data fetch. Please checked by your side. The above query is working very well.
    – Msquare
    Mar 25 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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