Skip to main content

getProductBlockById

Get ContentPageBlock objects by product identifier.

Description

This method Getting a product block object by product id. It returns a Promise that resolves to an array of product block objects IProductBlock.

Products.getProductBlockById(

id*

);

Parameters schema

Schema

id(required): number
Product id
example: 12345

Examples

Minimal example

const response = await Products.getProductBlockById(1764);

Example response

[
{
"id": 1,
"attributeSetIdentifier": null,
"localizeInfos": {
"title": "Product Block"
},
"version": 0,
"position": 1,
"identifier": "product_block",
"type": "product_block",
"customSettings": {
"productConfig": {
"quantity": "1",
"sortType": 0,
"sortOrder": 0,
"countElementsPerRow": "1"
},
"similarProductRules": [],
"condition": {
"name": "cost",
"costTo": 130,
"costFrom": 0
},
"sliderDelay": null,
"sliderDelayType": null
},
"templateIdentifier": null,
"isVisible": true,
"isSync": false,
"attributeValues": {}
}
]

Response schema

Schema: IProductBlock

id: number
Unique identifier of the product block.
example: 3289

attributeSetIdentifier: string | null
Identifier of the attribute set used in the product block, or null if not applicable.
example: "product_block"

localizeInfos: ILocalizeInfo
Localization information for the product block.
example:

{
"title": "Box"
}

version: number
Version of the product block entity.
example: 1

position: number
Position of the product block in a list or layout.
example: 1

identifier: string
Unique string identifier for the product block.
example: "product_block_12345"

type: Types
Type of the product block, such as "product", "error_page", etc.
example: "product"

customSettings: object
Custom settings for the product block, including slider delay, product configuration, similar product rules, and conditions.
example:

templateIdentifier: string | null
Identifier for the template used by the product block, or null if not applicable.
example: "template_12345"

isVisible: boolean
Indicates whether the product block is visible.
example: true

isSync: boolean
Indicates whether the product block is synchronized.
example: false

attributeValues: AttributeType
Array of attribute values from the index, represented as a pair of user attribute id and attribute value.
example:

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

sliderDelay: number | null
Slider auto-advance delay.
example: 5000

sliderDelayType: string | null
Unit of sliderDelay (e.g. "ms", "s").
example: "ms"

productConfig: IProductBlockProductConfig
Layout configuration for products inside the block.

productConfig.quantity: string | number
Number of products to render.
example: 9

productConfig.countElementsPerRow: string | number
Products per row.
example: 3

productConfig.sortType: string | number
Sort field.
example: "price"

productConfig.sortOrder: string | number
Sort direction.
example: "ASC"

similarProductRules: IProductBlockSimilarRule[]
Rules used to find similar products.

similarProductRules.property: string
Product property to match on.
example: "categories"

similarProductRules.includes: string
Match strategy (e.g. "any", "all").
example: "any"

similarProductRules.keywords: string
Keywords used for the match.
example: "foo,bar"

similarProductRules.strict: string
Strictness flag ("true"/"false") of the match.
example: "false"

condition: Record<string, unknown>
Filter condition applied to products in the block; field set varies by condition type (e.g. &#123; name: "cost", costFrom: 0, costTo: 130 &#125;).

frequentlyOrderedConfig: Record<string, unknown> | null
Configuration for the frequently-ordered products feature, or null when not configured.

quantity: string | number
Number of products to render.
example: 9

countElementsPerRow: string | number
Products per row.
example: 3

sortType: string | number
Sort field.
example: "price"

sortOrder: string | number
Sort direction.
example: "ASC"

property: string
Product property to match on.
example: "categories"

includes: string
Match strategy (e.g. "any", "all").
example: "any"

keywords: string
Keywords used for the match.
example: "foo,bar"

strict: string
Strictness flag ("true"/"false") of the match.
example: "false"