Skip to main content

getRelatedProductsById

Search for all related product objects by page id

Products.getRelatedProductsById(id, langCode, userQuery)

const value = await Products.getRelatedProductsById(1)
Schema

id: number
Product page identifier for which to find relationship
example: 12345

langCode: string
Language code. Default: "en_US"
example: "en_US"

userQuery: IProductsQuery
Optional set query parameters
example:

{
"offset": 0,
"limit": 30,
"sortOrder": "DESC",
"sortKey": "id"
}

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

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

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

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

templateMarker: string | null
Product page status id, default null.
example: "template_12345"

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

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

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

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

This method retrieves all related product page objects for a specific product based on its identifier (id) from the API. It accepts an optional userQuery parameter for additional query parameters such as offset, limit, sortOrder, and sortKey. It returns a Promise that resolves to an array of objects.

Example return:

{
"items": [],
"total": 0
}
Schema

total: number
The total number of products found.
example: 100

items: IProductsEntity[]
An array of product entities.
example:

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