Adobe Commerce 2.3 reached end of support in September 2022.

cmsBlocks query

The cmsBlocks query returns information about blocks that were developed with the Magento Content Management System (CMS).

Syntax

Return the contents of one or more CMS blocks:

cmsBlocks(identifiers: [String]): CmsBlocks

Example usage

The following query returns information about the login-data block:

Request:

1
2
3
4
5
6
7
8
9
{
  cmsBlocks(identifiers: "login-data") {
    items {
      identifier
      title
      content
    }
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "data": {
    "cmsBlocks": {
      "items": [
        {
          "identifier": "login-data",
          "title": "Login Info Block",
          "content": "<div class=\"message info\" style=\"margin-top: 50px;\">\n    <p><strong>Try Demo Customer Access</strong></p>\n    <p><span style=\"display:inline-block; width: 80px; padding-right: 10px;\">Email:</span>roni_cost@example.com</p>\n    <p><span style=\"display:inline-block; width: 80px; padding-right: 10px;\">Password:</span>roni_cost3@example.com</p>\n</div>"
        }
      ]
    }
  }
}

Input attributes

Attribute Data type Description
id Int Deprecated. Use identifier instead.
identifiers [String] An array containing a comma-separated list of block identifiers

Output attributes

The CmsBlocks object contains an array of items, each of which can contain a CmsBlock object.

CmsBlock attributes

The CmsBlock object can contain the following attributes:

Attribute Data type Description
content String The content of the CMS block in raw HTML
identifier String The CMS block identifier
title String The title assigned to the CMS block

Errors

Error Description
The CMS block with the "XXXX" ID doesn't exist The specified CMS block ID is invalid.
"identifiers" of CMS blocks should be specified" The identifiers array parameter is required for identifying the CMS blocks.