首页 > 解决方案 > Magento PWA Studio + 将下拉属性值(产品)检索到前端

问题描述

我正在使用 mageto PWA studio 开发一个电子商务网站。

我已经从 magento 管理面板创建了“主题”产品下拉属性。

我的要求是:我必须在产品详细信息页面中显示主题值。

为此,我在现有产品页面 GraphQL 查询中添加了以下查询:

第一次我尝试了以下方式

export const ProductDetailsFragment = gql`
    fragment ProductDetailsFragment on ProductInterface {
        __typename
        categories {
            id
            breadcrumbs {
                category_id
            }
        }
        description {
            html
        }
        id
        media_gallery_entries {
            id
            label
            position
            disabled
            file
        }
        meta_description
        name
        price {
            regularPrice {
                amount {
                    currency
                    value
                }
            }
        }
        sku
        small_image {
            url
        }
        url_key
        subject
    }
`;

输出:而不是主题值,它给出了主题的选项ID。

第二我尝试了以下方式

export const ProductDetailsFragment = gql`
    fragment ProductDetailsFragment on ProductInterface {
        __typename
        categories {
            id
            breadcrumbs {
                category_id
            }
        }
        description {
            html
        }
        id
        media_gallery_entries {
            id
            label
            position
            disabled
            file
        }
        meta_description
        name
        price {
            regularPrice {
                amount {
                    currency
                    value
                }
            }
        }
        sku
        small_image {
            url
        }
        url_key
        subject {
            label
            value
        }
    }
`;

输出:抛出控制台错误


我怎样才能摆脱这个问题..

标签: graphqlmagento2progressive-web-apps

解决方案


推荐阅读