Skip to main content

getAllTemplates

Getting all template objects of a specific type.

Description

This method retrieves all template objects grouped by types from the API. It returns a Promise that resolves to an object GroupedTemplatesObject, which contains an array of template objects.

Templates.getAllTemplates(

langCode

);

Parameters schema

Schema

langCode: string
Language code. Default: "en_US"
example: "en_US"

Examples

Minimal example

const response = await Templates.getAllTemplates();

Example with attributes

const response = await Templates.getAllTemplates('en_US');

Example response

{
"catalog_page": [
{
"id": 4,
"attributeSetIdentifier": null,
"title": "Template",
"generalTypeId": 4,
"identifier": "template",
"version": 0,
"generalTypeName": "catalog_page",
"attributeValues": {},
"position": 2
}
],
"product_preview": [
{
"id": 5,
"attributeSetIdentifier": null,
"title": "Product preview",
"generalTypeId": 5,
"identifier": "product_preview",
"version": 0,
"generalTypeName": "product_preview",
"attributeValues": {},
"position": 1
}
],
"product_block": [
{
"id": 6,
"attributeSetIdentifier": null,
"title": "block template",
"generalTypeId": 10,
"identifier": "block-template",
"version": 0,
"generalTypeName": "product_block",
"attributeValues": {},
"position": 3
}
]
}

Response schema

Schema: Record<Types, ITemplateEntity[]>