Saltar al contenido principal

getBlocks

Obteniendo todos los objetos de bloque

Blocks.getBlocks(type, langCode, offset, limit)

const value = await Blocks.getBlocks('forTextBlock')
Esquema

type:* BlockType
Valores disponibles: forCatalogProducts, forBasketPage, forErrorPage, forCatalogPages, forProductPreview, forProductPage, forSimilarProductBlock, forStatisticProductBlock, forProductBlock, forForm, forFormField, forNewsPage, forNewsBlock, forNewsPreview, forOneNewsPage, forUsualPage, forTextBlock, forSlider, forOrder, service
ejemplo: forTextBlock

langCode: string
Códigos de idioma
ejemplo: en_US

offset: number
Parámetro para paginación. Por defecto 0
ejemplo: 0

limit: number
Parámetro para paginación. Por defecto 30
ejemplo: 30

Este método devuelve un array de todos los objetos de bloque y el total.

Ejemplo de retorno:

{
"items": [
{
"id": 3,
"localizeInfos": {
"title": "Bloque"
},
"version": 0,
"position": 1,
"identifier": "block",
"type": "common_block",
"templateIdentifier": null,
"isVisible": true,
"attributeValues": {}
},
{
"id": 4,
"localizeInfos": {
"title": "prueba"
},
"version": 8,
"position": 2,
"identifier": "test",
"type": "common_block",
"templateIdentifier": null,
"isVisible": true,
"attributeValues": {
"block-text": {
"type": "string",
"value": "algún texto",
"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
}
Esquema

total: number
total de registros encontrados
ejemplo: 100

id: number
identificador del objeto ejemplo: 1764

attributeSetId: number
identificador del conjunto de atributos utilizado
ejemplo: 7

localizeInfos: CommonLocalizeInfos
nombre del bloque con localización
ejemplo:

{
"en_US": {
"title": "Mi bloque"
}
}

customSettings: BlockCustomSettings
configuraciones personalizadas para diferentes tipos de bloque
ejemplo:

{
"sliderDelay": 0,
"sliderDelayType": "",
"productQuantity": 4,
"productSortType": "By_ID",
"productSortOrder": "Descending",
"productCountElementsPerRow": 10,
"similarProductRules": [
{
"property": "Descending",
"includes": "",
"keywords": "",
"strict": ""
}
]
}

version: number
número de versión del objeto
ejemplo: 10

identifier: string
identificador textual para el registro del campo
ejemplo: catalog
por defecto: marker

position: number
número de posición (para ordenamiento)
ejemplo: 192

attributeValues: Record<string, string>
array de valores de atributos del índice (presentados como un par de identificador de atributo personalizado: valor de atributo)
ejemplo:

{
"en_US": {
"marker": {
"value": "",
"type": "string"
}
}
}

type: string
tipo de bloque
ejemplo: forNewsPage

templateIdentifier: string
marcador de plantilla utilizado por el bloque (puede ser nulo)
Enum: [ forCatalogProducts, forBasketPage, forErrorPage, forCatalogPages, forProductPreview, forProductPage, forSimilarProductBlock, forStatisticProductBlock, forProductBlock, forForm, forFormField, forNewsPage, forNewsBlock, forNewsPreview, forOneNewsPage, forUsualPage, forTextBlock, forSlider, service ]
ejemplo: null