getCartSimilarByProductIds
Get "similar to cart" products by an explicit list of productIds.
Description
This method returns products similar to an explicit list of product identifiers passed in the request body (instead of using the cart from context). It returns a Promise that resolves to an array of IProductsEntity objects.
Blocks.getCartSimilarByProductIds(
marker*,
body*,
body.productIds*,
body.langCode,
body.limit,
body.signPrice
);
Parameters schema
Schema
marker(required): string
Block marker
example: "cart_similar_block"
body(required): IBlockProductsLookup
Lookup body. Example: { productIds: [1, 2], langCode: "en_US" }
body.productIds(required): number[]
Product identifiers to look up.
example:
[
1,
2,
3
]
body.langCode: string
Language code. Default: "en_US"
example: "en_US"
body.limit: number
Max number of products to return.
example: 10
body.signPrice: string
Sign price
Examples
Minimal example
const response = await Blocks.getCartSimilarByProductIds('cart_similar_block', {
productIds: [1, 2, 3],
});
Example with attributes
const response = await Blocks.getCartSimilarByProductIds('cart_similar_block', {
productIds: [1, 2, 3],
langCode: 'en_US',
limit: 10,
});
Example response
[
{
"id": 1764,
"localizeInfos": {
"title": "Product"
},
"price": 100,
"additional": {
"prices": {
"min": 0,
"max": 100
}
},
"isVisible": true,
"isSync": true,
"sku": "0-123",
"attributeValues": {},
"attributeSetIdentifier": "my-set",
"statusIdentifier": "in_stock",
"statusLocalizeInfos": {
"title": "In stock"
},
"position": 1
}
]
Response schema
Schema: IProductsEntity[]
[]: IProductsEntity
A product entity.
[].id: number
The unique identifier.
example: 12345
[].localizeInfos: ILocalizeInfo
The localized name of the product.
example: { "title": "Product" }
[].price: number | null
The product page price taken from the index.
example: 100
[].sku: string | null
Product SKU (Stock Keeping Unit), may be null.
example: "SKU_12345"
[].attributeValues: IAttributeValues
Array of attribute values from the index.
[].statusIdentifier: string | null
Product page status identifier (may be null).
example: "in_stock"
[].isVisible: boolean
A sign of page visibility.
example: true
[].position: number
Item number (for sorting).
example: 1