getTemplateByType
Get all templates of a specific type.
Description
Fetches all templates of the given BlockType and resolves to an array of ITemplateEntity objects.
.getTemplateByType(
,
);
Parameters schema
Schema
type(required): BlockType
Type of templates to fetch. A type with no templates gives an empty array.
example: "product_block"
langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"
Examples
Minimal example
const response = await Templates.getTemplateByType('catalog_page');
Example with langCode
const response = await Templates.getTemplateByType('catalog_page', 'en_US');
Example response
[
{
"id": 4,
"attributeSetIdentifier": null,
"title": "Template",
"generalTypeId": 4,
"identifier": "template",
"version": 0,
"generalTypeName": "catalog_page",
"attributeValues": {},
"position": 1
}
]
Response schema
Schema: ITemplateEntity[]
id: number
ID of the object.
example: 12345
attributeSetIdentifier: string | null
Marker of the attribute set, or null if none is assigned.
example: "attribute_set_1"
title: string
Name of the template.
example: "Product Template"
generalTypeId: number
ID of the general type.
example: 67890
identifier: string
Text identifier (marker) of the object.
example: "template_12345"
version: number
Version number of the object; changes with each update.
example: 1
generalTypeName: BlockType
General type name.
example: "product_block"
attributeValues: IAttributeValues
Attribute values keyed by marker; an empty object when there are none.
example:
{
"color": {
"type": "string",
"value": "red",
"isIcon": false,
"position": 0,
"additionalFields": {}
}
}
position: number
Position of the object, used for sorting.
example: 1