انتقل إلى المحتوى الرئيسي

getRelatedProductsById

ابحث عن جميع كائنات المنتجات ذات الصلة بواسطة معرف الصفحة.

الوصف

تسترجع هذه الطريقة جميع كائنات صفحة المنتج ذات الصلة لمنتج معين بناءً على معرفه (id) من واجهة برمجة التطبيقات (API). تقبل معلمة userQuery الاختيارية لتمرير معلمات استعلام إضافية مثل offset و limit و sortOrder و sortKey. ترجع وعدًا (Promise) يتم حله إلى كائن IProductsResponse.

Products.getRelatedProductsById( id, langCode, userQuery );

مخطط المعلمات

المخطط

id: number
معرف صفحة المنتج الذي تريد العثور على العلاقة له
مثال: 12345

langCode: string
رمز اللغة. الافتراضي: "en_US"
مثال: "en_US"

userQuery: IProductsQuery
مجموعة معلمات الاستعلام الاختيارية
مثال:

{
"limit": 30,
"offset": 0,
"sortOrder": "DESC",
"sortKey": "id",
"signPrice": "orders",
"templateMarker": "template_12345",
"statusMarker": "in_stock",
"conditionValue": "new",
"conditionMarker": "eq",
"attributeMarker": "color"
}

userQuery.offset(required): number
معلمة للتقسيم. الافتراضي: 0.

userQuery.limit(required): number
معلمة للتقسيم. الافتراضي: 30.

userQuery.sortOrder(required): string
ترتيب الفرز "DESC" | "ASC". الافتراضي: "DESC".

userQuery.sortKey(required): string
الحقل المستخدم للفرز (الافتراضي - null). القيم الممكنة: "id"، "position"، "title"، "date"، "price". الافتراضي: null.

userQuery.signPrice: string
علامة السعر. الافتراضي: null.

userQuery.templateMarker: string | null
علامة قالب صفحة المنتج، الافتراضي null.
مثال: "template_12345"

userQuery.statusMarker: string | null
علامة حالة صفحة المنتج، الافتراضي null.
مثال: "in_stock"

userQuery.conditionValue: string | null
القيمة التي يتم البحث عنها، الافتراضي null.
مثال: "new"

userQuery.attributeMarker: string | null
معرف النص الساكن للخاصية المفهرسة التي يتم تصفية القيم بناءً عليها، الافتراضي null.
مثال: "color"

userQuery.conditionMarker: string | null
علامة شرط الفلتر الذي يتم تصفية القيم بناءً عليه، الافتراضي null.
مثال: "equals"

userQuery.langCode: string
رمز اللغة. الافتراضي: "en_US".

userQuery.ids: string
قائمة معرفات المنتجات مفصولة بفواصل — تستخدم بواسطة getProductsByIds.
مثال: "1,2,3"

بشكل افتراضي، يمكنك استرجاع 10 كائنات. وذلك بسبب حد السجلات في إعدادات أذونات الوحدة.
لعمل التقسيم بشكل صحيح، تحتاج إلى تكوين أذونات الوحدة وفقًا لاحتياجاتك في القسم المقابل.

أمثلة

مثال بسيط

const response = await Products.getRelatedProductsById(1);

مثال مع الخصائص


const userQuery = {
"offset": 0,
"limit": 30,
"sortOrder": "DESC",
"sortKey": "id"
};

const response = await Products.getRelatedProductsById(1, 'en_US', userQuery);

استخدم الشروط للعثور على بيانات منتجات محددة:

attributeMarker: معرف النص للخاصية المفهرسة التي يتم تصفية القيم بناءً عليها. conditionMarker: نوع الشرط الذي سيتم تطبيقه على قيمة الخاصية.

العلامةالمعنىالمثال
eqيساويstatusId = 1 (نشط فقط)
neqلا يساويrole ≠ "Viewer"
inيحتوي على (واحد من)role in ["Editor", "Manager"]
ninلا يحتوي علىemail not in ["@temp.com"]
exsموجود (له قيمة)Has lastLogin
nexsغير موجودلم يسجل الدخول أبدًا

conditionValue: القيمة التي سيتم المقارنة بها.

مثال على الاستجابة

{
"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
}
}
}
]
}

مخطط الاستجابة

المخطط: IProductsResponse

total: number
إجمالي عدد المنتجات التي تم العثور عليها.
مثال: 100

items: IProductsEntity[]
مصفوفة من كائنات المنتجات.
مثال:

[
{
"id": 12345,
"title": "Product 1"
},
{
"id": 67890,
"title": "Product 2"
}
]

items.id: number
المعرف الفريد.
مثال: 12345

items.localizeInfos: ILocalizeInfo
اسم المنتجات، مع الأخذ في الاعتبار التوطين.
مثال:

items.statusIdentifier: string | null
معرفات حالة صفحة المنتج (قد تكون null).
مثال: "in_stock"

items.statusLocalizeInfos: ILocalizeInfo
اسم الحالة المحلي للمنتج.
مثال: { "title": "Sale" }

items.attributeSetIdentifier: string | null
مجموعة معرفات الخصائص.
مثال: "set_12345"

items.position: number
رقم العنصر (لأغراض الفرز).
مثال: 1

items.price: number | null
قيمة سعر صفحة المنتج المأخوذة من الفهرس.
مثال: 150.00

items.additional: object
قيمة إضافية من الفهرس.
مثال: { prices: { min: 5 max: 150 } }

items.sku: string | null
SKU المنتج (وحدة حفظ المخزون)، قد تكون null.
مثال: "SKU_12345"

items.isSync: boolean
إشارة إلى فهرسة الصفحة.
مثال: true

items.attributeValues: AttributeType
مصفوفة من قيم الخصائص من الفهرس، ممثلة.
مثال:

[
{
"id": "color",
"value": "red"
}
]

items.categories: string[]
فئات المنتجات.
مثال:

[
1,
2,
3
]

items.isVisible: boolean
علامة رؤية الصفحة.
مثال: true

items.moduleFormConfigs: Array<IFormConfig>
إعدادات نماذج الوحدة (اختياري).

items.rating: IRating
بيانات التقييم.

items.isPositionLocked: boolean
مؤشر قفل موضع الفرز (اختياري).
مثال: false

items.relatedIds: number[]
معرفات صفحات المنتجات ذات الصلة.
مثال:

[
12345,
67890
]

items.paymentStages: unknown
بيانات مراحل الدفع (قد تكون null).
مثال: null

items.discountConfig: Record<string, unknown>
كائن إعدادات الخصم.
مثال:

items.templateIdentifier: string | null
معرف المستخدم للقالب المرتبط.
مثال: "template_12345"

items.shortDescTemplateIdentifier: string | null
معرف المستخدم للقالب المرتبط لوصف قصير.
مثال: "short_desc_template_12345"

items.signedPrice: string
علامة السعر.

items.productPages: IProductPageRef[]
مصفوفة من مراجع صفحات المنتجات تربط المنتج بصفحاتها.
مثال:

[
{
"id": 16,
"pageId": 4,
"productId": 15,
"positionId": 244,
"categoryPath": "products"
}
]

productPages.id: number
المعرف الفريد لسجل ارتباط المنتج بالصفحة.
مثال: 16

productPages.pageId: number
معرف الصفحة التي يرتبط بها المنتج.
مثال: 4

productPages.productId: number
معرف المنتج.
مثال: 15

productPages.positionId: number
معرف موضع الفرز داخل الصفحة.
مثال: 244

productPages.categoryPath: string
مسار الفئة للصفحة التي ينتمي إليها المنتج.
مثال: "products"

items.blocks: string[]
مصفوفة من معرفات الكتل.
مثال:

[
"block_12345",
"block_67890"
]