I want to get the attribute label value along with the id in the Products graphQL query.
like color { id: 12, label: black }, size{ id: 15, label: xl }
Currently, it returns the id only.
How can I extend the current query?
Viral Patel
1,1001 gold badge8 silver badges17 bronze badges
asked Nov 9, 2021 at 8:06
Jancy Abraham
2,7148 gold badges48 silver badges76 bronze badges
1 Answer 1
Try This
query($url: String!) {
products(filter: { url_key: { eq: $url } }) {
items {
id
sku
name
... on ConfigurableProduct {
configurable_options {
id
attribute_id_v2
use_default
attribute_code
label
position
values {
value_index
label
swatch_data {
__typename
value
}
}
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
}
}
}
}
}
}
}
total_count
}
}
answered Nov 9, 2021 at 8:30
Msquare
9,4627 gold badges30 silver badges71 bronze badges
-
this is for configurable products. I want this data in all simple products tooJancy Abraham– Jancy Abraham2021年11月09日 08:51:58 +00:00Commented Nov 9, 2021 at 8:51
-
if the product is configurable then it's showing all its variants. Simple product does not have any variantMsquare– Msquare2021年11月10日 05:57:43 +00:00Commented Nov 10, 2021 at 5:57
-
Simple products can also have various attributes with option/value combination.Afreen Sheikh– Afreen Sheikh2022年11月11日 12:43:22 +00:00Commented Nov 11, 2022 at 12:43
default