Product Variant Name using GraphQL in Bigcommerce

680 views Asked by At

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

2

There are 2 answers

4
Tony McCreath On BEST ANSWER

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
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
1
Nathan Booker On

Variants do not have their own names (they only have a SKU code), so you can simply re-use the product's name. You can add the name field to your query underneath the product node, on the same level as variants.