Nhảy đến nội dung

getBlocksByPageUrl

Nhận các đối tượng cho một khối liên quan theo URL trang.

Mô tả

Lấy các đối tượng PositionBlock cho trang theo URL. Nó trả về một Promise mà khi hoàn thành sẽ trả về một mảng các đối tượng IPositionBlock.

Pages.getBlocksByPageUrl(

url*, langCode

);

Sơ đồ tham số

Sơ đồ

url(bắt buộc): string
URL trang
ví dụ: "about"

langCode: string
Mã ngôn ngữ. Mặc định: "en_US"
ví dụ: "en_US"

Ví dụ

Ví dụ tối thiểu

const response = await Pages.getBlocksByPageUrl('shop');

Ví dụ với các thuộc tính

const response = await Pages.getBlocksByPageUrl('shop', 'en_US');

Ví dụ phản hồi

[
{
"id": 1,
"attributeSetIdentifier": null,
"localizeInfos": {
"title": "Product Block"
},
"isVisible": true,
"version": 0,
"position": 1,
"identifier": "product_block",
"type": "product_block",
"templateIdentifier": null,
"isSync": false,
"attributeValues": {}
},
{
"id": 4,
"attributeSetIdentifier": "block",
"localizeInfos": {
"title": "test"
},
"isVisible": true,
"version": 31,
"position": 2,
"identifier": "test",
"type": "common_block",
"templateIdentifier": null,
"isSync": true,
"attributeValues": {
"block-text": {
"type": "string",
"value": "some text",
"position": 0,
"additionalFields": {}
},
"interval": {
"type": "timeInterval",
"value": [
{
"values": [
{
"id": "bbc82c9f-1bc4-4c86-b83c-c062016eb7cb",
"dates": [
"2025-04-14T00:00:00.000Z",
"2025-04-14T00:00:00.000Z"
],
"times": [
[
{
"hours": 9,
"minutes": 0
},
{
"hours": 10,
"minutes": 0
}
],
[
{
"hours": 10,
"minutes": 0
},
{
"hours": 11,
"minutes": 0
}
],
[
{
"hours": 11,
"minutes": 0
},
{
"hours": 12,
"minutes": 0
}
],
"..."
],
"intervals": [],
"exceptions": [],
"intervalId": "c6466cd8-c55d-4583-97c5-42b684210f12",
"inEveryWeek": true,
"inEveryMonth": true,
"timeIntervals": [
[
"2025-04-07T09:00:00.000Z",
"2025-04-07T10:00:00.000Z"
],
[
"2025-04-07T10:00:00.000Z",
"2025-04-07T11:00:00.000Z"
],
[
"2025-04-07T11:00:00.000Z",
"2025-04-07T12:00:00.000Z"
],
"..."
]
}
],
"intervalId": "c6466cd8-c55d-4583-97c5-42b684210f12"
}
],
"position": 1,
"additionalFields": {}
}
}
},
{
"id": 6,
"attributeSetIdentifier": null,
"localizeInfos": {
"title": "Frequently ordered"
},
"isVisible": true,
"version": 1,
"position": 3,
"identifier": "freq_ordered",
"type": "frequently_ordered_block",
"templateIdentifier": null,
"isSync": false,
"attributeValues": {}
}
]

Sơ đồ phản hồi

Sơ đồ: IPositionBlock[]

id: number
Định danh của đối tượng.
ví dụ: 1

attributeSetIdentifier: string | null
Tập hợp các id thuộc tính.
ví dụ: "block"

localizeInfos: ILocalizeInfo
Tên của trang, tính đến việc địa phương hóa.
ví dụ:

{
"title": "Blog",
"menuTitle": "Blog",
"htmlContent": "",
"plainContent": ""
}

version: number
Số phiên bản của đối tượng.
ví dụ: 0

position: number
Vị trí của đối tượng.
ví dụ: 1

identifier: string
Định danh văn bản cho trường bản ghi.
ví dụ: "product_block"

type: Types
Loại trang.
ví dụ: "product"

templateIdentifier: string | null
ID người dùng của mẫu liên kết.
ví dụ: null

isVisible: boolean
Dấu hiệu của sự hiển thị trang.
ví dụ: true

isSync: boolean
Chỉ báo về việc lập chỉ mục trang.
ví dụ: false

attributeValues: IAttributeValues
Bản đồ các giá trị thuộc tính được khóa theo dấu hiệu; đối tượng rỗng khi không có.
ví dụ:

{
"block-text": {
"type": "string",
"value": "some text",
"position": 0,
"additionalFields": []
}
}

countElementsPerRow: number
Số lượng phần tử hiển thị trên mỗi hàng trong khối, nếu có.
ví dụ: 3

quantity: number
Số lượng trang trong khối.
ví dụ: 1