Skip to main content

getProductsByIds

Getting multiple products by its ids.

Description

This method retrieves a products objects based on its identifiers (ids) from the API. It returns a Promise that resolves to a IProductsEntity objects for the product.

Products.getProductsByIds( ids, langCode, userQuery );

Parameters schema

Schema

ids(required): string
Product page identifiers for which to find relationships
example: "12345,67890"

langCode: string
Language code. Default "en_US"

userQuery: IProductsQuery
Optional set query parameters
example:

{
"limit": 30,
"offset": 0,
"sortOrder": "DESC",
"sortKey": "id",
"statusId": 123,
"statusMarker": "in_stock",
"conditionValue": "new",
"conditionMarker": "equals",
"attributeMarker": "color"
}

userQuery.offset(required): number
Parameter for pagination. Default: 0.

userQuery.limit(required): number
Parameter for pagination. Default: 30.

userQuery.sortOrder(required): string
Sort order "DESC" | "ASC". Default: "DESC".

userQuery.sortKey(required): string
Field for sorting (default - null). Possible values: "id", "position", "title", "date", "price". Default: null.

userQuery.templateMarker: string | null
Product page template marker, default null.
example: "template_12345"

userQuery.statusMarker: string | null
Product page status marker, default null.
example: "in_stock"

userQuery.conditionValue: string | null
The value that is being searched for, default null.
example: "new"

userQuery.attributeMarker: string | null
The text identifier of the indexed attribute by which values are filtered, default null.
example: "color"

userQuery.conditionMarker: string | null
Marker of the filter condition by which the values are filtered, default null.
example: "equals"

By default, you can retrieve 10 objects. This is due to the record limit in the module's permissions settings.
For pagination to work correctly, you need to configure Module permissions according to your needs in the corresponding section.

Examples

Minimal example

const response = await Products.getProductsByIds('1, 5, 8');

Example with attributes

const userQuery = {
"offset": 0,
"limit": 30,
"sortOrder": "DESC",
"sortKey": "id"
};
const response = await Products.getProductsByIds('1, 5, 8', 'en_US', userQuery);

Example response

[
{
"id": 2954,
"attributeSetIdentifier": "products",
"localizeInfos": {
"title": "Box"
},
"statusLocalizeInfos": {
"title": "Sale"
},
"isVisible": true,
"statusIdentifier": "sale",
"position": 1,
"templateIdentifier": null,
"shortDescTemplateIdentifier": "product_preview",
"price": 51,
"additional": {
"prices": {
"min": 51,
"max": 150
}
},
"sku": null,
"isSync": true,
"categories": [
"catalog"
],
"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": {
"size": 241636,
"filename": "files/project/product/2954/image/7e0a6a70-a23d-410f-8b6a-f8b4f7483244.png",
"downloadLink": "https://your-project.oneentry.cloud/cloud-static/files/project/product/2954/image/7e0a6a70-a23d-410f-8b6a-f8b4f7483244.png"
},
"isIcon": false,
"position": 3,
"additionalFields": [],
"isProductPreview": false
}
},
"productPages": [
{
"id": 2847,
"pageId": 10,
"productId": 2954,
"positionId": 3190,
"categoryPath": "catalog"
}
],
"blocks": [
"product_block",
"product_block"
]
},
{
"id": 2955,
"attributeSetIdentifier": null,
"localizeInfos": {
"title": "Product"
},
"statusLocalizeInfos": {
"title": "Sale"
},
"isVisible": true,
"statusIdentifier": "sale",
"position": 2,
"templateIdentifier": null,
"shortDescTemplateIdentifier": null,
"price": null,
"additional": {
"prices": {
"min": 51,
"max": 150
}
},
"sku": null,
"isSync": false,
"categories": [
"catalog"
],
"attributeValues": {},
"productPages": [
{
"id": 2848,
"pageId": 10,
"productId": 2955,
"positionId": 3191,
"categoryPath": "catalog"
}
],
"blocks": [
"product_block",
"product_block"
]
}
]

Response schema

Schema: IProductsEntity[]

id: number
The unique identifier.
example: 12345

localizeInfos: ILocalizeInfo
The name of the products, taking into account localization.
example:

statusIdentifier: string | null
Product page status identifiers (may be null).
example: "in_stock"

statusLocalizeInfos: any
JSON description of the item status object, taking into account the language.
example:

attributeSetIdentifier: string | null
Set of attributes id.
example: "set_12345"

position: number
Item number (for sorting).
example: 1

templateIdentifier: string | null
User id of the linked template.
example: "template_12345"

shortDescTemplateIdentifier: string | null
User id of the linked template for a short description.
example: "short_desc_template_12345"

price: number
The value of the product page price taken from the index.
example: 150

additional: object
Additional value from the index.
example:

{
"en": "In Stock",
"de": "Auf Lager"
}

sku: string | null
Product SKU (Stock Keeping Unit), may be null.
example: "SKU_12345"

isSync: boolean
Indication of page indexing.
example: true

attributeValues: AttributeType
Array of attribute values from the index, represented.
example:

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

categories: string[]
Product categories.
example:

[
1,
2,
3
]

isVisible: boolean
A sign of page visibility.
example: true

productPages: any
Array of product pages or a single product page object.
example: []

blocks: string[]
Array of block identifiers.
example:

[
"block_12345",
"block_67890"
]

isPositionLocked: boolean
Sorting position lock indicator (optional).
example: false

relatedIds: number[]
Ids of related product pages.
example:

[
12345,
67890
]