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

getProductById

احصل على كائن منتج واحد بواسطة المعرف.

الوصف

تسترجع هذه الطريقة كائن منتج واحد بناءً على معرفه (id) من واجهة برمجة التطبيقات (API). تعيد Promise التي تحل إلى كائن للمنتج IProductsEntity.

Products.getProductById(

id, langCode

);

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

المخطط

id: number
معرف المنتج
مثال: 12345

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

أمثلة

مثال بسيط

const response = await Products.getProductById(1);

مثال مع السمات

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

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

{
"id": 2954,
"localizeInfos": {
"title": "صندوق"
},
"statusIdentifier": "sale",
"statusLocalizeInfos": {
"title": "تخفيض"
},
"attributeSetIdentifier": "products",
"position": 1,
"templateIdentifier": null,
"shortDescTemplateIdentifier": "product_preview",
"price": 51,
"additional": {
"prices": {
"min": 51,
"max": 150
}
},
"sku": null,
"isSync": true,
"attributeValues": {
"product-name": {
"type": "string",
"value": "product-name",
"isIcon": false,
"position": 0,
"additionalFields": [],
"isProductPreview": false
},
"price": {
"type": "integer",
"value": 51,
"isIcon": false,
"position": 1,
"additionalFields": [],
"isProductPreview": false
},
"currency_products": {
"type": "string",
"value": "usd",
"isIcon": false,
"position": 2,
"additionalFields": [],
"isProductPreview": false
},
"img": {
"type": "image",
"value": [],
"isIcon": false,
"position": 3,
"additionalFields": [],
"isProductPreview": false
}
},
"categories": [
"catalog"
],
"isVisible": true,
"productPages": [
{
"id": 2847,
"pageId": 10,
"productId": 2954,
"positionId": 3190,
"categoryPath": "catalog"
}
],
"blocks": [
"product_block"
],
"moduleFormConfigs": []
}

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

المخطط: IProductsEntity

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

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

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

statusLocalizeInfos: any
وصف JSON لكائن حالة العنصر، مع الأخذ في الاعتبار اللغة.

attributeSetIdentifier: string | null
مجموعة معرفات السمات.
مثال: "set_12345"

position: number
رقم العنصر (للتصنيف).
مثال: 1

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

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

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

additional: object
قيمة إضافية من الفهرس.
مثال:

{
"en": "متوفر",
"de": "متوفر"
}

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

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

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

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

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

[
1,
2,
3
]

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

productPages: any[]
مصفوفة من صفحات المنتجات أو كائن صفحة منتج واحد.

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

[
"block_12345",
"block_67890"
]

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

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

[
12345,
67890
]