getAllTemplates
Get all templates, grouped by type.
Description
Fetches every template, grouped by type. Resolves to an object keyed by BlockType (Record<BlockType, ITemplateEntity[]>), where each value is the array of templates of that type. When the request fails, the method currently resolves to an empty object ({}) instead of an IError.
.getAllTemplates(
);
Parameters schema
Schema
langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"
Examples
Minimal example
const response = await Templates.getAllTemplates();
Example with langCode
const response = await Templates.getAllTemplates('en_US');
Example response
{
"frequently_ordered_block": [
{
"id": 7,
"attributeSetIdentifier": null,
"title": "Default frequently ordered block template",
"generalTypeId": 24,
"identifier": "frequently_ordered_block_default",
"version": 0,
"generalTypeName": "frequently_ordered_block",
"attributeValues": {},
"position": 1
}
],
"slider_block": [
{
"id": 8,
"attributeSetIdentifier": null,
"title": "Default slider block template",
"generalTypeId": 25,
"identifier": "slider_block_default",
"version": 0,
"generalTypeName": "slider_block",
"attributeValues": {},
"position": 2
}
],
"trending_block": [
{
"id": 9,
"attributeSetIdentifier": null,
"title": "Default trending block template",
"generalTypeId": 26,
"identifier": "trending_block_default",
"version": 0,
"generalTypeName": "trending_block",
"attributeValues": {},
"position": 3
}
],
"recently_viewed_block": [
{
"id": 10,
"attributeSetIdentifier": null,
"title": "Default recently viewed block template",
"generalTypeId": 27,
"identifier": "recently_viewed_block_default",
"version": 0,
"generalTypeName": "recently_viewed_block",
"attributeValues": {},
"position": 4
}
],
"repeat_purchase_block": [
{
"id": 11,
"attributeSetIdentifier": null,
"title": "Default repeat purchase block template",
"generalTypeId": 28,
"identifier": "repeat_purchase_block_default",
"version": 0,
"generalTypeName": "repeat_purchase_block",
"attributeValues": {},
"position": 5
}
],
"personal_recommendations_block": [
{
"id": 12,
"attributeSetIdentifier": null,
"title": "Default personal recommendations block template",
"generalTypeId": 29,
"identifier": "personal_recommendations_block_default",
"version": 0,
"generalTypeName": "personal_recommendations_block",
"attributeValues": {},
"position": 6
}
],
"cart_complement_block": [
{
"id": 13,
"attributeSetIdentifier": null,
"title": "Default cart complement block template",
"generalTypeId": 30,
"identifier": "cart_complement_block_default",
"version": 0,
"generalTypeName": "cart_complement_block",
"attributeValues": {},
"position": 7
}
],
"cart_similar_block": [
{
"id": 14,
"attributeSetIdentifier": null,
"title": "Default cart similar block template",
"generalTypeId": 31,
"identifier": "cart_similar_block_default",
"version": 0,
"generalTypeName": "cart_similar_block",
"attributeValues": {},
"position": 8
}
],
"wishlist_similar_block": [
{
"id": 15,
"attributeSetIdentifier": null,
"title": "Default wishlist similar block template",
"generalTypeId": 32,
"identifier": "wishlist_similar_block_default",
"version": 0,
"generalTypeName": "wishlist_similar_block",
"attributeValues": {},
"position": 9
}
],
"catalog_page": [
{
"id": 4,
"attributeSetIdentifier": null,
"title": "Template",
"generalTypeId": 4,
"identifier": "template",
"version": 0,
"generalTypeName": "catalog_page",
"attributeValues": {},
"position": 12
}
],
"product_preview": [
{
"id": 5,
"attributeSetIdentifier": null,
"title": "Product preview",
"generalTypeId": 5,
"identifier": "product_preview",
"version": 0,
"generalTypeName": "product_preview",
"attributeValues": {},
"position": 10
}
],
"product_block": [
{
"id": 6,
"attributeSetIdentifier": null,
"title": "block template",
"generalTypeId": 10,
"identifier": "block-template",
"version": 0,
"generalTypeName": "product_block",
"attributeValues": {},
"position": 11
}
]
}
Response schema
Schema: Record<BlockType, 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