Menu
The Menu API returns the store's navigation menus and the nested items inside one menu. Both endpoints are open to anonymous visitors.
All Ajax API requests should use locale-aware URLs to give visitors a consistent experience.
List the navigation menus of the store
GET /{locale}/api/front/menus
List the navigation menus of the store, each with its nested items. Takes no parameters.
Example request
fetch(window.SHOPLAZZA.routes.root + '/api/front/menus')
.then((response) => response.json())
.then((data) => {
// do something...
});
Response
- Schema
- Example
- Array [
- Array [
- ]
- ]
data object[]
The response payload.
ID of the navigation menu.
Name of the navigation menu.
children object[]
Sub-items of this navigation item.
ID of the navigation item.
Label shown for the navigation item.
Type of resource the navigation item links to, for example home, page or collection.
ID of the resource the navigation item links to.
Relative URL the navigation item links to.
ID of the parent navigation item; 0 for a top-level item.
Link target of the navigation item, for example _blank to open a new tab.
url_obj object
Structured link information of the navigation item.
Type of resource the navigation item links to, for example home, page or collection.
ID of the resource the navigation item links to.
Relative URL the navigation item links to.
Label shown for the navigation item.
Result message returned with the response.
Request result flag; success or 0 means the request succeeded.
{
"data": [
{
"id": "header",
"title": "Main menu",
"category": 1,
"children": [
{
"id": 83850217,
"title": "Home",
"origin_type": 15,
"type": "home",
"source_id": "0",
"url": "/",
"pid": 0,
"status": 0,
"disabled": 0,
"target": "",
"url_obj": {
"type": "home",
"source_id": "0",
"url": "/",
"title": ""
},
"expanded": true
},
{
"id": 83850219,
"title": "New Arrivals",
"origin_type": 3,
"type": "page",
"source_id": "0",
"url": "",
"pid": 0,
"status": 0,
"disabled": 0,
"target": "",
"url_obj": {
"type": "page",
"source_id": "0",
"url": "",
"title": ""
},
"expanded": true,
"children": [
{
"id": 83850221,
"title": "Collection",
"origin_type": 2,
"type": "collection",
"source_id": "0",
"url": "",
"pid": 83850219,
"status": 0,
"disabled": 0,
"target": "",
"url_obj": {
"type": "collection",
"source_id": "0",
"url": "",
"title": ""
},
"expanded": true
}
]
}
]
}
],
"msg": "请求成功",
"state": 0
}
Get a navigation menu
GET /{locale}/api/front/menus/{menu_id}
Get one navigation menu with its nested items. menu_id is the handle of the menu, such as header or footer.
Example request
fetch(window.SHOPLAZZA.routes.root + '/api/front/menus/header')
.then((response) => response.json())
.then((data) => {
// do something...
});
Request parameters
The handle of the menu, such as header.
Response
- Schema
- Example
- Array [
- ]
data object
The response payload.
ID of the navigation menu.
Name of the navigation menu.
children object[]
Sub-items of this navigation item.
ID of the navigation item.
Label shown for the navigation item.
Type of resource the navigation item links to, for example home, page or collection.
ID of the resource the navigation item links to.
Relative URL the navigation item links to.
ID of the parent navigation item; 0 for a top-level item.
Link target of the navigation item, for example _blank to open a new tab.
url_obj object
Structured link information of the navigation item.
Type of resource the navigation item links to, for example home, page or collection.
ID of the resource the navigation item links to.
Relative URL the navigation item links to.
Label shown for the navigation item.
Result message returned with the response.
Request result flag; success or 0 means the request succeeded.
{
"data": {
"id": "header",
"title": "Main menu",
"category": 1,
"children": [
{
"id": 83850217,
"title": "Home",
"origin_type": 15,
"type": "home",
"source_id": "0",
"url": "/",
"pid": 0,
"status": 0,
"disabled": 0,
"target": "",
"url_obj": {
"type": "home",
"source_id": "0",
"url": "/",
"title": ""
},
"expanded": true
},
{
"id": 83850219,
"title": "New Arrivals",
"origin_type": 3,
"type": "page",
"source_id": "0",
"url": "",
"pid": 0,
"status": 0,
"disabled": 0,
"target": "",
"url_obj": {
"type": "page",
"source_id": "0",
"url": "",
"title": ""
},
"expanded": true,
"children": [
{
"id": 83850221,
"title": "Collection",
"origin_type": 2,
"type": "collection",
"source_id": "0",
"url": "",
"pid": 83850219,
"status": 0,
"disabled": 0,
"target": "",
"url_obj": {
"type": "collection",
"source_id": "0",
"url": "",
"title": ""
},
"expanded": true
}
]
}
]
},
"msg": "请求成功",
"state": 0
}