getBlocks
Getting all block objects.
Description
This method return array of all blocks object and total. It returns a Promise that resolves to an IBlocksResponse object.
Blocks.getBlocks(
type*,
langCode,
offset,
limit
);
Parameters schema
Schema
type(required): BlockType
Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none"
example: 'product'
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
By default, you can retrieve 10 objects. This is due to the record limit in the module's permissions settings.
For pagination to work correctly, you need to configure Module permissions according to your needs in the corresponding section.
Examples
Minimal example
const response = await Blocks.getBlocks('forTextBlock');
Example with attributes
const response = await Blocks.getBlocks('forTextBlock', 'en_US', 0, 30);
Example response
{
"items": [
{
"id": 3,
"localizeInfos": {
"title": "Block"
},
"version": 0,
"position": 1,
"identifier": "block",
"type": "common_block",
"templateIdentifier": null,
"isVisible": true,
"attributeValues": {}
},
{
"id": 4,
"localizeInfos": {
"title": "test"
},
"version": 31,
"position": 2,
"identifier": "test",
"type": "common_block",
"templateIdentifier": null,
"isVisible": true,
"attributeValues": {
"block-text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
},
"interval": {
"type": "timeInterval",
"value": [
{
"values": [
{
"id": "bbc82c9f-1bc4-4c86-b83c-c062016eb7cb",
"dates": [
"2025-04-14T00:00:00.000Z",
"2025-04-14T00:00:00.000Z"
],
"times": [
[
{
"hours": 9,
"minutes": 0
},
{
"hours": 10,
"minutes": 0
}
],
[
{
"hours": 10,
"minutes": 0
},
{
"hours": 11,
"minutes": 0
}
],
[
{
"hours": 11,
"minutes": 0
},
{
"hours": 12,
"minutes": 0
}
],
"..."
],
"intervals": [],
"exceptions": [],
"intervalId": "c6466cd8-c55d-4583-97c5-42b684210f12",
"inEveryWeek": true,
"inEveryMonth": true,
"timeIntervals": [
[
"2025-04-07T09:00:00.000Z",
"2025-04-07T10:00:00.000Z"
],
[
"2025-04-07T10:00:00.000Z",
"2025-04-07T11:00:00.000Z"
],
[
"2025-04-07T11:00:00.000Z",
"2025-04-07T12:00:00.000Z"
],
"..."
]
}
],
"intervalId": "c6466cd8-c55d-4583-97c5-42b684210f12"
}
],
"isIcon": false,
"position": 1,
"additionalFields": {},
"isProductPreview": false
}
}
}
],
"total": 2
}
Response schema
Schema: IBlocksResponse
total: number
Total number of found records.
example: 100
items: IBlockEntity[]
Array of block entities.
example:
[
{
"attributeValues": {},
"id": 1,
"identifier": "block1",
"isVisible": true,
"localizeInfos": {
"key": "value"
},
"position": 1,
"templateIdentifier": null,
"type": "product",
"version": 1,
"countElementsPerRow": 3,
"quantity": 9,
"similarProducts": {
"total": 0,
"items": []
},
"products": [
{
"id": 1,
"name": "Product 1"
},
{
"id": 2,
"name": "Product 2"
}
]
}
]
items.attributeValues: IAttributeValues
Map of attribute values keyed by marker; empty object when none.
example:
{
"block-text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": [],
"isProductPreview": false
}
}
items.id: number
Unique identifier of the block.
example: 1234
items.localizeInfos: ILocalizeInfo
Localization information for the block.
example:
{
"key": "value"
}
items.version: number
Version of the block entity.
example: 1
items.identifier: string
Unique string identifier for the block.
example: "block1"
items.type: BlockType
Type of the block.
example: "product"
items.position: number
Position of the block for sorting.
example: 1
items.templateIdentifier: string | null
Identifier for the template used by the block, or null if not applicable.
example: "template1"
items.isVisible: boolean
Indicates whether the block is visible.
example: true
items.countElementsPerRow: number
Number of elements displayed per row in the block, if applicable.
example: 3
items.quantity: number
Quantity of items in the block, if applicable.
example: 5
items.similarProducts: IProductsResponse
Response containing similar products associated with the block.
example:
{
"total": 10,
"items": []
}
similarProducts.total: number
The total number of products found.
example: 100
similarProducts.items: IProductsEntity[]
An array of product entities.
example:
[
{
"id": 12345,
"title": "Product 1"
},
{
"id": 67890,
"title": "Product 2"
}
]
items.id: number
The unique identifier.
example: 12345
items.localizeInfos: ILocalizeInfo
The name of the products, taking into account localization.
example:
items.statusIdentifier: string | null
Product page status identifiers (may be null).
example: "in_stock"
items.statusLocalizeInfos: ILocalizeInfo
Localized status name for the product.
example: { "title": "Sale" }
items.attributeSetIdentifier: string | null
Set of attributes id.
example: "set_12345"
items.position: number
Item number (for sorting).
example: 1
items.price: number | null
The value of the product page price taken from the index.
example: 150.00
items.additional: object
Additional value from the index.
example: { prices: { min: 5 max: 150 } }
items.sku: string | null
Product SKU (Stock Keeping Unit), may be null.
example: "SKU_12345"
items.isSync: boolean
Indication of page indexing.
example: true
items.attributeValues: IAttributeValues
Array of attribute values from the index, represented.
example:
[
{
"id": "color",
"value": "red"
}
]
items.categories: string[]
Product categories.
example:
[
1,
2,
3
]
items.isVisible: boolean
A sign of page visibility.
example: true
items.moduleFormConfigs: Array<IFormConfig>
Module form configurations (optional).
items.rating: IRating
Rating data.
items.isPositionLocked: boolean
Sorting position lock indicator (optional).
example: false
items.relatedIds: number[]
Ids of related product pages.
example:
[
12345,
67890
]
items.paymentStages: unknown
Payment stages data (may be null).
example: null
items.discountConfig: Record<string, unknown>
Discount configuration object.
example:
items.templateIdentifier: string | null
User id of the linked template.
example: "template_12345"
items.shortDescTemplateIdentifier: string | null
User id of the linked template for a short description.
example: "short_desc_template_12345"
items.signedPrice: string
Price sign.
items.productPages: IProductPageRef[]
Array of product page references linking the product to its pages.
example:
[
{
"id": 16,
"pageId": 4,
"productId": 15,
"positionId": 244,
"categoryPath": "products"
}
]
productPages.id: number
Unique identifier of the product-to-page link record.
example: 16
productPages.pageId: number
Identifier of the page the product is linked to.
example: 4
productPages.productId: number
Identifier of the product.
example: 15
productPages.positionId: number
Sorting position identifier within the page.
example: 244
productPages.categoryPath: string
Category path of the page the product belongs to.
example: "products"
items.blocks: string[]
Array of block identifiers.
example:
[
"block_12345",
"block_67890"
]
items.products: IProductsEntity[]
Array of product entities associated with the block.
example:
[
{
"id": 1,
"name": "Product 1"
},
{
"id": 2,
"name": "Product 2"
}
]