Skip to main content

getBlockByMarker

Getting a single block object by marker.

Description

This method return one blocks object by marker. It returns a Promise that resolves to an IBlockEntity object.

Blocks.getBlockByMarker(

marker, langCode, offset, limit

);

Parameters schema

Schema

marker(required): string
Marker of Block
example: "product_block"

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

offset: number
Parameter for pagination. Default: 0
example: 0

limit: number
Parameter for pagination. Default: 30
example: 30

Examples

Minimal example

const response = await Blocks.getBlockByMarker('my-marker');

Example with attributes

const response = await Blocks.getBlockByMarker('my-marker', 'en_US', 0, 30);

Example response

{
"id": 3,
"localizeInfos": {
"title": "Block"
},
"version": 0,
"position": 1,
"identifier": "block",
"type": "common_block",
"templateIdentifier": null,
"isVisible": true,
"attributeValues": {}
}

Response schema

Schema: IBlockEntity

attributeValues: AttributeType
Type of attributes used in the block.
example:

{
"block-text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": [],
"isProductPreview": false
}
}

id: number
Unique identifier of the block.
example: 1234

localizeInfos: ILocalizeInfo
Localization information for the block.
example:

{
"key": "value"
}

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

identifier: string
Unique string identifier for the block.
example: "block1"

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

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

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

countElementsPerRow: number
Number of elements displayed per row in the block, if applicable.
example: 3

quantity: number
Quantity of items in the block, if applicable.
example: 5

similarProducts: IProductsResponse
Response containing similar products associated with the block.
example:

{
"total": 10,
"items": []
}

products: IProductsEntity[]
Array of product entities associated with the block.
example:

[
{
"id": 1,
"name": "Product 1"
},
{
"id": 2,
"name": "Product 2"
}
]