searchPage
Search pages by title.
Description
Searches pages by the text in name and resolves to an array of IPagesEntity objects, or [] when nothing matches. With traficLimit: true in the defineOneEntry config, it resolves to short IPageSearchResult cards instead.
The search runs in langCode. Results keep the search order; a page that matches but can't be loaded in that language is left out.
Matching is a case-insensitive substring match on the title. url limits the result to the page with that exact pageUrl; it doesn't search inside a section.
What you get depends on traficLimit
The declared return type is IPagesEntity[] | IPageSearchResult[] | IError:
| Config | Result | Contains |
|---|---|---|
traficLimit: false (default) | IPagesEntity[] | Full page entities, with attributeValues, localizeInfos, … |
traficLimit: true | IPageSearchResult[] | The raw quick-search card: only { id, title } |
Short cards have no attributeValues, and the call can also resolve to an IError, so narrow the result before reading it:
const found = await Pages.searchPage('cat');
if (!Array.isArray(found)) {
// IError: the request failed
} else if (found.length === 0) {
// nothing matched
} else if ('attributeValues' in found[0]) {
// IPagesEntity[]: traficLimit is off
} else {
// IPageSearchResult[]: short { id, title } cards
}
Short cards carry no templateIdentifier, so the SDK doesn't look up a template for them.
.searchPage(
,
,
);
Parameters schema
Schema
name(required): string
Text to search for in page titles (localizeInfos.title) in the requested language.
example: "About Us"
url: string
Page URL.
example: "catalog"
langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"
Examples
Minimal example
const response = await Pages.searchPage('cat');
Example with langCode
The second argument is url; pass undefined to leave it out:
const response = await Pages.searchPage('cat', undefined, 'en_US');
Example response
[
{
"id": 10,
"parentId": null,
"pageUrl": "catalog",
"depth": 0,
"localizeInfos": {
"title": "Catalog",
"htmlContent": "",
"plainContent": "",
"menuTitle": "Catalog"
},
"isVisible": true,
"blocks": [
"product_block",
"test",
"freq_ordered"
],
"type": "catalog_page",
"templateIdentifier": "template",
"attributeSetIdentifier": "page",
"attributeValues": {
"text": {
"type": "string",
"value": "catalog text",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
},
"number": {
"type": "integer",
"value": 10,
"isIcon": false,
"position": 1,
"additionalFields": {},
"isProductPreview": false
},
"real": {
"type": "real",
"value": 5,
"isIcon": false,
"position": 2,
"additionalFields": {},
"isProductPreview": false
},
"float": {
"type": "float",
"value": 15,
"isIcon": false,
"position": 3,
"additionalFields": {},
"isProductPreview": false
}
},
"moduleFormConfigs": [],
"isSync": true,
"template": {
"id": 4,
"attributeSetIdentifier": null,
"title": "Template",
"generalTypeId": 4,
"identifier": "template",
"version": 0,
"generalTypeName": "catalog_page",
"attributeValues": {},
"position": 1
}
}
]
Response schema
Schema: IPagesEntity[] | IPageSearchResult[]
id: number
Object ID.
example: 8
parentId: number | null
ID of the parent page; null for a top-level page.
example: 10
pageUrl: string
URL of the page.
example: "blog"
depth: number
Nesting level of the page: 0 for a top-level page, 1 for its children, and so on.
example: 10
localizeInfos: ILocalizeInfo
Localized page content: title, menuTitle, htmlContent and plainContent.
example:
{
"title": "Blog",
"menuTitle": "Blog",
"htmlContent": "",
"plainContent": ""
}
isVisible: boolean
Whether the page is visible.
example: true
type: PageType
Page type.
example: "common_page"
templateIdentifier: string | null
Marker of the linked template.
example: "template"
attributeSetIdentifier: string | null
Marker of the attribute set, or null if none is assigned.
example: "page"
attributeValues: IAttributeValues
Attribute values keyed by marker; an empty object when there are none.
example:
{
"text": {
"type": "string",
"value": "some text",
"position": 0,
"additionalFields": {}
}
}
isSync: boolean
Whether the page's attribute index is up to date for the requested language.
example: true
template: object
Template linked to the page.
example:
{}
position: number
Position used for sorting.
example: 2
config: Record<string, number>
Output settings for catalog pages.
example:
{
"rowsPerPage": 1,
"productsPerRow": 1
}
products: number
Number of products linked to the page.
example: 0
childrenCount: number
Number of child pages.
example: 1
blocks: IBlockEntity[] | string[]
Blocks attached to the page: block objects or their markers.
example:
[
"product_block"
]
blocks.attributeValues: IAttributeValues
Attribute values keyed by marker; an empty object when there are none.
example:
{
"block-text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
}
}
blocks.id: number
ID of the block.
example: 1234
blocks.localizeInfos: ILocalizeInfo
Localized data of the block.
example:
{
"title": "Example title"
}
blocks.version: number
Version number of the block.
example: 1
blocks.identifier: string
Marker of the block.
example: "block1"
blocks.type: BlockType
Type of the block.
example: "product"
blocks.position: number
Position of the block, used for sorting.
example: 1
blocks.templateIdentifier: string | null
Marker of the template used by the block, or null.
example: "template1"
blocks.isVisible: boolean
Whether the block is visible.
example: true
blocks.countElementsPerRow: number
Number of items per row in the block, if set.
example: 3
blocks.quantity: number
Quantity of items in the block, if applicable.
example: 5
blocks.similarProducts: IProductsResponse
Similar products for the block, as total and items.
example:
{
"total": 10,
"items": []
}
blocks.products: IProductsEntity[]
Products linked to the block.
example:
[
{
"id": 1,
"name": "Product 1"
},
{
"id": 2,
"name": "Product 2"
}
]
moduleFormConfigs: Array<IFormConfig>
Form configurations of the module linked to the page.
rating: IRating
Rating data: average value, likes and dislikes, and the calculation method.
total: string
Not returned by the Content API; use products for the number of linked products.
example: "10"
categoryPath: string | null
Category path; null for nested pages that have no category path of their own.
example: "catalog"
distance: number
Cosine distance to the query. Returned on every item by the semantic (vector) search endpoint.
example: 0.12