質問

I want to get the values for custom product attribute in product details page. I am using below GrapgQl query to get the values. i am passing the name as the argument. How can i get the products attributes.

{
products(filter:{name: {eq: "Joust Duffle Bag"}}
                    ){
items{
  id
  sku
  special_price
  description{ html}
  short_description{ html}
  meta_title
  meta_keyword
  meta_description
  options_container
  type_id
  image{ url label }
  small_image{ url label }
  thumbnail{ url label }
  price{  
    regularPrice{
      amount{ 
        value
        currency
      }
    }
  }
}
}
}
役に立ちましたか?

解決

After some searches we dont need any special query methods to retriew custom attributes. We can just pass the custom attribute code to the query.

EX - our custom attribute code is publisher just pass it in the query.

{
products(filter:{name: {eq: "Joust Duffle Bag"}}
                ){
items{
id
sku
publisher
price{  
regularPrice{
  amount{ 
    value
    currency
  }
}
}
}
}
}

to get the custom attribute values and label if it was the multiple select or select type refer How to get product attribute value, label using GraphQl in Magento 2.3?

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top