Search code examples
graphqlbigcommercegraphql-jsgqlbigcommerce-stencil-cli

Product Variant Name using GraphQL in Bigcommerce


I'm using GQL query to show product variant information inside my table but when I'm calling product name its not working. Even my SKU,UPC/MPN and all rest values are showing but don't know how to show product name. This is my site theme table Table And this is my dashboard Dashboard Table This is my GQL query through which I'm taking variant information Code


Solution

  • Variants are associated with options that do have names. We gather the names for all options and concatenate them together to get the variant's name. e.g. "Large Red".

    Here's the variant part of the graphql we use to get that information:

    variants(first:50 entityIds:[1,2,3]){
        edges{
            node{
                options(first:50){
                    edges{
                        node{
                            displayName values(first:50){
                                edges{
                                    node{
                                        label
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }