Skip to main content

getBlockByMarker

Get a single block by its marker.

Description​

Fetches a block by its marker and resolves to an IBlockEntity. For product_block and similar_products_block blocks, the SDK also loads the block's products into products or similarProducts, using offset and limit for that request. With traficLimit: true in the defineOneEntry config, it skips that extra request.

.getBlockByMarker(

, , ,

);

Parameters schema​

Schema

marker(required): string
Marker of the block.
example: "product_block"

langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"

offset: number
Number of records to skip. Default: 0. offset + limit must not exceed 200; a larger window is rejected with 400.
example: 0

limit: number
Maximum number of records to return. Default: 30.
example: 30

offset and limit apply only to the products the SDK loads for product_block and similar_products_block blocks.

Examples​

Minimal example​

const response = await Blocks.getBlockByMarker('footer');

Example with all parameters​

const response = await Blocks.getBlockByMarker('footer', 'en_US', 0, 30);

Example response​

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

Response schema​

Schema: IBlockEntity

attributeValues: IAttributeValues
Attribute values keyed by marker; an empty object when there are none.
example:

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

id: number
ID of the block.
example: 1234

localizeInfos: ILocalizeInfo
Localized data of the block.
example:

{
"title": "Example title"
}

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

identifier: string
Marker of the block.
example: "block1"

type: BlockType
Type of the block.
example: "product_block"

position: number
Position of the block, used for sorting.
example: 1

templateIdentifier: string | null
Marker of the template used by the block, or null.
example: "template1"

isVisible: boolean
Whether the block is visible.
example: true

countElementsPerRow: number
Number of items per row in the block, if set.
example: 3

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

similarProducts: IProductsResponse
Similar products for the block, as total and items.
example:

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

similarProducts.total: number
Total number of products found.
example: 100

similarProducts.items: IProductsEntity[]
Products in this response.
example:

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

similarProducts.totalFound: number
Number of products matched before limits are applied; returned by block product endpoints (similarProducts, cart/wishlist recommendations, frequently ordered). Optional.
example: 2

products: IProductsEntity[]
Products linked to the block.
example:

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

products.id: number
ID of the product.
example: 12345

products.localizeInfos: ILocalizeInfo
Localized product data, such as the title.
example:

{}

products.statusIdentifier: string | null
Marker of the product status, or null.
example: "in_stock"

products.statusLocalizeInfos: ILocalizeInfo
Localized status name for the product.
example:

{ "title": "Sale" }

products.attributeSetIdentifier: string | null
Marker of the attribute set, or null if none is assigned.
example: "set_12345"

products.position: number
Position used for sorting. Present on catalog/list/ids//blocks entities; absent from vector (semantic) search results, so typed optional.
example: 1

products.price: number | null
Product price from the search index.
example: 150.00

products.additional: object
Extra values computed by the search index, such as the price range in prices.min and prices.max.
example:

{
"prices": {
"min": 5,
"max": 150
}
}

products.sku: string | null
Product SKU from the search index, or null.
example: "SKU_12345"

products.isSync: boolean
Whether the product's attribute index is up to date for the requested language. When false, an empty or partial attributeValues means the values are not published yet, not that there are none.
example: true

products.attributeValues: IAttributeValues
Attribute values keyed by attribute marker (an object, not an array).
example:

{
"product-name": {
"type": "string",
"value": "Split",
"position": 0
},
"price": {
"type": "integer",
"value": 150,
"position": 1
}
}

products.categories: string[]
URLs of the catalog pages the product belongs to.
example:

[
"catalog"
]

products.isVisible: boolean
Whether the product is visible.
example: true

products.moduleFormConfigs: Array<IFormConfig>
Form configurations of the module.

products.rating: IRating
Rating data: average value, likes and dislikes, and the calculation method.

products.isPositionLocked: boolean
Whether the sorting position is locked.
example: false

products.relatedIds: number[]
IDs of related products.
example:

[
12345,
67890
]

products.paymentStages: unknown
Payment stages of the product: an array of { title, value, marker } objects, or null when none are set.
example: null

products.distance: number
Relevance distance in vector (semantic) search. Present only in vector search results.
example: 0.42

products.discountConfig: Record<string, unknown>
Discount configuration.
example:

{}

products.templateIdentifier: string | null
Marker of the linked template.
example: "template_12345"

products.shortDescTemplateIdentifier: string | null
Marker of the template used for the short description.
example: "short_desc_template_12345"

products.signedPrice: string
Signed token (JWT) that fixes the product price for an order. Returned when signPrice is set.
see: Fixed product price
example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

products.productPages: IProductPageRef[]
Links between the product and the catalog pages it belongs to.
example:

[
{
"id": 16,
"pageId": 4,
"productId": 15,
"positionId": 244,
"categoryPath": "products"
}
]

products.blocks: string[]
Markers of the blocks shown on the product page (not the blocks whose selection includes the product).
example:

[
"block_12345",
"block_67890"
]