如何在Shopify Storefront API中获取首页内容?

问题描述 投票:0回答:1

我正在使用菜单查询通过 Shopify GraphQL API 获取主菜单。

它返回了我的菜单项,所有这些看起来都不错。

{
"data": {
    "menu": {
        "id": "gid://shopify/Menu/888734372",
        "title": "Main menu",
        "itemsCount": 4,
        "items": [
            {
                "id": "gid://shopify/MenuItem/62623462",
                "title": "Home",
                "type": "FRONTPAGE",
                "url": "https:/test.myshopify.com/",
                "resourceId": null
            },
            {
                "id": "gid://shopify/MenuItem/251532",
                "title": "Electronics",
                "type": "COLLECTION",
                "url": "https://test.myshopify.com/collections/catalog",
                "resourceId": "gid://shopify/Collection/26262"
            },
            {
                "id": "gid://shopify/MenuItem/888888",
                "title": "Clothing & Accessories",
                "type": "CATALOG",
                "url": "https://test.myshopify.com/collections/all",
                "resourceId": null
            }, 
            {
                "id": "gid://shopify/MenuItem/111111",
                "title": "About",
                "type": "PAGE",
                "url": "https:/test.myshopify.com/pages/about",
                "resourceId": "gid://shopify/Page/111111"
            }
        ]
    }
}
}

它包含 FRONTPAGE 类型的菜单项,这是客户端的主页。

我如何进行查询以获得该首页/主页内容的响应?

当我打开商店首页时,我可以看到有一些这样的商品:

  • 幻灯片

  • 热门产品列表

  • 发售清单

  • 男士时尚清单

shopify shopify-app shopify-api shopify-storefront-api
1个回答
0
投票

当您需要特定页面及其关联数据时,可以使用管理 API 的页面端点。如:https://shopify.dev/docs/api/admin-rest/2024-01/resources/page

这至少会给你基础知识。可能不是列表,因为这些东西将被隐藏在其他模板方面。

© www.soinside.com 2019 - 2024. All rights reserved.