Get information about specific product and specific attribute values in specific language

This is an example of how you can get values of specific attributes in specific languages of a specific product using pagination.

Please keep in mind that this is just an example and more data can be pulled. How to deal with other attribute types can be seen in the fragment AttributeValue here.

query getAttValues {
    product(sku: "0123456789") {
        # SKU of a single product to get data from
        sku
        createdAt
        editedAt
        template {
            code
        }
        attributeList(
            first: 10 # nuber of entries to return in a single page (max response time is 60s)
            after: "YXJyYXljb25uZWN0aW9uOjA=" # endCursor from the response to get rest of the data if "hasNextPage": true
            codes: [
                # attributes to get values from
                "name"
                "color"
                "short_description"
                "price_local_eur"
                "galeria_zdjec"
            ]
        ) {
            ... on AttributeValueConnection {
                pageInfo {
                    hasNextPage
                    endCursor
                }
                edges {
                    node {
                        ... on PriceAttributeValue {
                            priceAttribute: attribute {
                                # currency might be useful in the price context
                                currency
                            }
                            priceAttributeValue: translations(
                                languages: ["en_GB", "pl_PL"]
                            ) {
                                language
                                value
                            }
                        }
                        ... on SelectAttributeValue {
                            SelectAttributeValue: translations(
                                languages: ["en_GB", "pl_PL"]
                            ) {
                                language
                                translatedValue {
                                    ...OptionTranslatedValue
                                }
                            }
                        }
                        ... on TextAttributeValue {
                            attribute {
                                name(languages: ["en_GB", "pl_PL"]) {
                                    language
                                    value
                                }
                            }
                            TextAttributeValue: translations(
                                languages: ["en_GB", "pl_PL"]
                            ) {
                                language
                                value
                            }
                        }
                        ... on TextareaAttributeValue {
                            attribute {
                                name(languages: ["en_GB", "pl_PL"]) {
                                    language
                                    value
                                }
                            }
                            TextareaAttributeValue: translations(
                                languages: ["en_GB", "pl_PL"]
                            ) {
                                language
                                value
                            }
                        }
                        ... on GalleryAttributeValue {
                            GalleryAttributeValue: translations {
                                language
                                value {
                                    ...Multimedia
                                }
                            }
                        }
                    }
                }
            }
        }
        __typename
    }
}

fragment Multimedia on Multimedia {
    path
    name
    extension
    mime
    sizeInBytes: size
    alt(languages: ["en_GB", "pl_PL"]) {
        language
        value
    }
    title(languages: ["en_GB", "pl_PL"]) {
        language
        value
    }
}
fragment OptionTranslatedValue on OptionTranslatedValue {
    code
    name
}

Last updated