getRelatedProductsById
Tìm kiếm tất cả các đối tượng sản phẩm liên quan theo id trang.
Mô tả
Phương thức này lấy tất cả các đối tượng trang sản phẩm liên quan cho một sản phẩm cụ thể dựa trên định danh (id) của nó từ API. Nó chấp nhận một tham số userQuery tùy chọn cho các tham số truy vấn bổ sung như offset, limit, sortOrder và sortKey. Nó trả về một Promise mà khi hoàn thành sẽ trả về một đối tượng IProductsResponse.
Products.getRelatedProductsById(
id,
langCode,
userQuery
);
Sơ đồ tham số
Sơ đồ
id: number
Định danh trang sản phẩm mà bạn muốn tìm mối quan hệ
ví dụ: 12345
langCode: string
Mã ngôn ngữ. Mặc định: "en_US"
ví dụ: "en_US"
userQuery: IProductsQuery
Tham số truy vấn tùy chọn
ví dụ:
{
"limit": 30,
"offset": 0,
"sortOrder": "DESC",
"sortKey": "id",
"signPrice": "orders",
"templateMarker": "template_12345",
"statusMarker": "in_stock",
"conditionValue": "new",
"conditionMarker": "eq",
"attributeMarker": "color"
}
userQuery.offset(bắt buộc): number
Tham số cho phân trang. Mặc định: 0.
userQuery.limit(bắt buộc): number
Tham số cho phân trang. Mặc định: 30.
userQuery.sortOrder(bắt buộc): string
Thứ tự sắp xếp "DESC" | "ASC". Mặc định: "DESC".
userQuery.sortKey(bắt buộc): string
Trường để sắp xếp (mặc định - null). Các giá trị có thể: "id", "position", "title", "date", "price". Mặc định: null.
userQuery.signPrice: string
Đánh dấu lưu trữ đơn hàng cho việc cố định giá. Nếu tham số này được thiết lập, giá sẽ được cố định trong một khoảng thời gian nhất định.
userQuery.templateMarker: string | null
Đánh dấu mẫu trang sản phẩm, mặc định null.
ví dụ: "template_12345"
userQuery.statusMarker: string | null
Đánh dấu trạng thái trang sản phẩm, mặc định null.
ví dụ: "in_stock"
userQuery.conditionValue: string | null
Giá trị mà bạn đang tìm kiếm, mặc định null.
ví dụ: "new"
userQuery.attributeMarker: string | null
Định danh văn bản của thuộc tính đã được lập chỉ mục mà theo đó các giá trị được lọc, mặc định null.
ví dụ: "color"
userQuery.conditionMarker: string | null
Đánh dấu điều kiện lọc mà theo đó các giá trị được lọc, mặc định null.
ví dụ: "equals"
userQuery.langCode: string
Mã ngôn ngữ. Mặc định: "en_US".
userQuery.ids: string
Danh sách id sản phẩm phân cách bằng dấu phẩy — được sử dụng bởi getProductsByIds.
ví dụ: "1,2,3"
Mặc định, bạn có thể lấy 10 đối tượng. Điều này là do giới hạn bản ghi trong cài đặt quyền của mô-đun.
Để phân trang hoạt động chính xác, bạn cần cấu hình Quyền mô-đun theo nhu cầu của bạn trong phần tương ứng.
💲
signPricekhóa giá đã trả về trong một khoảng thời gian giới hạn — hãy thiết lập nó thành đánh dấu lưu trữ đơn hàng của bạn. Xem Cố định giá (signPrice).
Ví dụ
Ví dụ tối thiểu
const response = await Products.getRelatedProductsById(1);
Ví dụ với các thuộc tính
const userQuery = { "offset": 0, "limit": 30, "sortOrder": "DESC", "sortKey": "id"};
const response = await Products.getRelatedProductsById(1, 'en_US', userQuery);
Sử dụng các điều kiện để tìm dữ liệu sản phẩm cụ thể:
attributeMarker: Định danh văn bản của thuộc tính đã được lập chỉ mục mà theo đó các giá trị được lọc. conditionMarker: Loại điều kiện để áp dụng cho giá trị thuộc tính.
| Đánh dấu | Ý nghĩa | Ví dụ |
|---|---|---|
| eq | Bằng | statusId = 1 (chỉ hoạt động) |
| neq | Không bằng | role ≠ "Viewer" |
| in | Chứa (một trong số) | role in ["Editor", "Manager"] |
| nin | Không chứa | email not in ["@temp.com"] |
| exs | Tồn tại (có giá trị) | Có lastLogin |
| nexs | Không tồn tại | Chưa bao giờ đăng nhập |
conditionValue: Giá trị để so sánh.
Ví dụ phản hồi
{
"total": 15,
"items": [
{
"localizeInfos": {
"title": "Товар"
},
"paymentStages": [
{
"title": "Part A",
"marker": "part_a",
"value": 100
},
{
"title": "Part B",
"marker": "part_b",
"value": 200
}
],
"id": 1764,
"isVisible": true,
"isSync": true,
"price": 0,
"additional": {
"prices": {
"min": 0,
"max": 100
}
},
"blocks": [],
"sku": "0-123",
"productPages": [
{
"id": 8997,
"pageId": 1176,
"productId": 8872
}
],
"rating": {
"votes": 42,
"value": 4.5,
"like": 10,
"dislike": 2,
"method": "weighted"
},
"statusLocalizeInfos": {
"title": "Товар"
},
"templateIdentifier": "my-template",
"shortDescTemplateIdentifier": "my-template-short",
"attributeValues": {
"marker": {
"value": "",
"type": "string",
"position": 1,
"isProductPreview": false,
"isIcon": false,
"additionalFields": {
"marker": {
"type": "string",
"value": "test"
}
}
}
},
"attributeSetIdentifier": "my-set",
"statusIdentifier": "my-status",
"position": 1,
"signedPrice": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"formModuleConfigs": [
{
"id": 1,
"formIdentifier": "reg",
"moduleIdentifier": "user",
"entityIdentifiers": [],
"isGlobal": true,
"isClosed": false,
"viewOnlyMyData": false,
"commentOnlyMyData": false,
"formDataCount": 0,
"entityFormDataCount": {},
"exceptionIds": [
"shop"
],
"nestedEntityIdentifiers": [
"avto-aksessuary",
"fm-moduliatory",
"avtomobilnye-derzhateli",
"videoregistratory-radiolokatory"
],
"ratingCalculation": "average",
"allowHalfRatings": true,
"maxRatingScale": 5,
"isAnonymous": true,
"allowRerating": true,
"isRating": true
}
],
"discountConfig": {
"discounts": [
{
"id": 5,
"identifier": "summer-sale",
"type": "DISCOUNT",
"localizeInfos": {
"title": "Summer Sale"
},
"startDate": "2026-01-01T06:32:19.736Z",
"endDate": "2026-01-28T06:32:22.632Z",
"discountValue": {
"value": 30,
"maxAmount": 0,
"discountType": "FIXED_PRICE",
"applicability": "TO_PRODUCT"
},
"exclusions": [
{
"id": 2
}
],
"position": 3,
"conditionLogic": "OR",
"gifts": [
{
"id": 3,
"localizeInfos": {
"title": "hhh222"
},
"attributeSetIdentifier": "attr-set-1",
"statusIdentifier": null,
"statusLocalizeInfos": {},
"templateIdentifier": null,
"price": 90,
"sku": null,
"attributeValues": {
"price1": {
"type": "integer",
"value": "90",
"isIcon": false,
"position": 0,
"additionalFields": [],
"isProductPreview": false
}
},
"isVisible": true
}
],
"conditions": [
{
"conditionType": "PRODUCT",
"entityIds": [
{
"id": 4,
"isNested": false
},
{
"isNested": false
}
],
"value": null
},
{
"conditionType": "ATTRIBUTE",
"entityIds": [
{
"isNested": false
}
],
"value": {
"value": "100",
"condition": "eq"
}
}
]
}
],
"discountPrice": 90,
"settings": {
"allowStacking": true,
"maxDiscountValue": 30,
"allowGiftStacking": false
}
}
},
{
"localizeInfos": {
"title": "Товар"
},
"paymentStages": [
{
"title": "Part A",
"marker": "part_a",
"value": 100
},
{
"title": "Part B",
"marker": "part_b",
"value": 200
}
],
"id": 1764,
"isVisible": true,
"isSync": true,
"price": 0,
"additional": {
"prices": {
"min": 0,
"max": 100
}
},
"blocks": [],
"sku": "0-123",
"productPages": [
{
"id": 8997,
"pageId": 1176,
"productId": 8872
}
],
"rating": {
"votes": 42,
"value": 4.5,
"like": 10,
"dislike": 2,
"method": "weighted"
},
"statusLocalizeInfos": {
"title": "Товар"
},
"templateIdentifier": "my-template",
"shortDescTemplateIdentifier": "my-template-short",
"attributeValues": {
"marker": {
"value": "",
"type": "string",
"position": 1,
"isProductPreview": false,
"isIcon": false,
"additionalFields": {
"marker": {
"type": "string",
"value": "test"
}
}
}
},
"attributeSetIdentifier": "my-set",
"statusIdentifier": "my-status",
"position": 1,
"signedPrice": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"formModuleConfigs": [
{
"id": 1,
"formIdentifier": "reg",
"moduleIdentifier": "user",
"entityIdentifiers": [],
"isGlobal": true,
"isClosed": false,
"viewOnlyMyData": false,
"commentOnlyMyData": false,
"formDataCount": 0,
"entityFormDataCount": {},
"exceptionIds": [
"shop"
],
"nestedEntityIdentifiers": [
"avto-aksessuary",
"fm-moduliatory",
"avtomobilnye-derzhateli",
"videoregistratory-radiolokatory"
],
"ratingCalculation": "average",
"allowHalfRatings": true,
"maxRatingScale": 5,
"isAnonymous": true,
"allowRerating": true,
"isRating": true
}
],
"discountConfig": {
"discounts": [
{
"id": 5,
"identifier": "summer-sale",
"type": "DISCOUNT",
"localizeInfos": {
"title": "Summer Sale"
},
"startDate": "2026-01-01T06:32:19.736Z",
"endDate": "2026-01-28T06:32:22.632Z",
"discountValue": {
"value": 30,
"maxAmount": 0,
"discountType": "FIXED_PRICE",
"applicability": "TO_PRODUCT"
},
"exclusions": [
{
"id": 2
}
],
"position": 3,
"conditionLogic": "OR",
"gifts": [
{
"id": 3,
"localizeInfos": {
"title": "hhh222"
},
"attributeSetIdentifier": "attr-set-1",
"statusIdentifier": null,
"statusLocalizeInfos": {},
"templateIdentifier": null,
"price": 90,
"sku": null,
"attributeValues": {
"price1": {
"type": "integer",
"value": "90",
"isIcon": false,
"position": 0,
"additionalFields": [],
"isProductPreview": false
}
},
"isVisible": true
}
],
"conditions": [
{
"conditionType": "PRODUCT",
"entityIds": [
{
"id": 4,
"isNested": false
},
{
"isNested": false
}
],
"value": null
},
{
"conditionType": "ATTRIBUTE",
"entityIds": [
{
"isNested": false
}
],
"value": {
"value": "100",
"condition": "eq"
}
}
]
}
],
"discountPrice": 90,
"settings": {
"allowStacking": true,
"maxDiscountValue": 30,
"allowGiftStacking": false
}
}
}
]
}
Sơ đồ phản hồi
Sơ đồ: IProductsResponse
total: number
Tổng số sản phẩm được tìm thấy.
ví dụ: 100
items: IProductsEntity[]
Mảng các thực thể sản phẩm.
ví dụ:
[
{
"id": 12345,
"title": "Product 1"
},
{
"id": 67890,
"title": "Product 2"
}
]
items.id: number
Định danh duy nhất.
ví dụ: 12345
items.localizeInfos: ILocalizeInfo
Tên của các sản phẩm, tính đến việc địa phương hóa.
ví dụ:
{}
items.statusIdentifier: string | null
Định danh trạng thái trang sản phẩm (có thể là null).
ví dụ: "in_stock"
items.statusLocalizeInfos: ILocalizeInfo
Tên trạng thái đã được địa phương hóa cho sản phẩm.
ví dụ:
{ "title": "Sale" }
items.attributeSetIdentifier: string | null
Tập hợp các id thuộc tính.
ví dụ: "set_12345"
items.position: number
Số thứ tự mục (để sắp xếp).
ví dụ: 1
items.price: number | null
Giá trị của giá trang sản phẩm lấy từ chỉ mục.
ví dụ: 150.00
items.additional: object
Giá trị bổ sung từ chỉ mục.
ví dụ:
{
"prices": {
"min": 5,
"max": 150
}
}
items.sku: string | null
SKU sản phẩm (Đơn vị lưu kho), có thể là null.
ví dụ: "SKU_12345"
items.isSync: boolean
Chỉ báo về việc lập chỉ mục trang.
ví dụ: true
items.attributeValues: IAttributeValues
Mảng các giá trị thuộc tính từ chỉ mục, được đại diện.
ví dụ:
[
{
"id": "color",
"value": "red"
}
]
items.categories: string[]
Danh mục sản phẩm.
ví dụ:
[
1,
2,
3
]
items.isVisible: boolean
Dấu hiệu về tính khả thi của trang.
ví dụ: true
items.moduleFormConfigs: Array<IFormConfig>
Cấu hình biểu mẫu mô-đun (tùy chọn).
items.rating: IRating
Dữ liệu đánh giá.
items.isPositionLocked: boolean
Chỉ báo khóa vị trí sắp xếp (tùy chọn).
ví dụ: false
items.relatedIds: number[]
Id của các trang sản phẩm liên quan.
ví dụ:
[
12345,
67890
]
items.paymentStages: unknown
Dữ liệu các giai đoạn thanh toán (có thể là null).
ví dụ: null
items.distance: number
Khoảng cách liên quan đến tìm kiếm vector (ngữ nghĩa). Chỉ có trong kết quả của tìm kiếm vector.
ví dụ: 0.42
items.discountConfig: Record<string, unknown>
Đối tượng cấu hình giảm giá.
ví dụ:
{}
items.templateIdentifier: string | null
Id người dùng của mẫu liên kết.
ví dụ: "template_12345"
items.shortDescTemplateIdentifier: string | null
Id người dùng của mẫu liên kết cho mô tả ngắn.
ví dụ: "short_desc_template_12345"
items.signedPrice: string
Giá đã ký của sản phẩm được lấy cùng với dữ liệu sản phẩm khi signPrice được thiết lập.
ví dụ: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
items.productPages: IProductPageRef[]
Mảng các tham chiếu trang sản phẩm liên kết sản phẩm với các trang của nó.
ví dụ:
[
{
"id": 16,
"pageId": 4,
"productId": 15,
"positionId": 244,
"categoryPath": "products"
}
]
items.blocks: string[]
Mảng các định danh khối.
ví dụ:
[
"block_12345",
"block_67890"
]
🔒
signedPricelà token đã ký mang giá đã khóa — hãy truyền lại khi bạn tạo đơn hàng. Xem Giá sản phẩm cố định (signedPrice).