searchPage
Pencarian cepat untuk objek halaman dengan output terbatas.
Deskripsi
Metode ini melakukan pencarian cepat untuk objek halaman berdasarkan kueri teks (nama). Ini mengembalikan Promise yang menyelesaikan menjadi array objek IPagesEntity, array kosong [] ketika tidak ada yang ditemukan - atau, dengan traficLimit: true, array kartu IPageSearchResult yang pendek.
Apa yang Anda dapatkan tergantung pada traficLimit
Tipe pengembalian yang dinyatakan adalah IPagesEntity[] | IPageSearchResult[] | IError:
| Konfigurasi | Hasil | Berisi |
|---|---|---|
traficLimit: false (default) | IPagesEntity[] | Entitas halaman lengkap, dengan attributeValues, localizeInfos, … |
traficLimit: true | IPageSearchResult[] | Kartu pencarian cepat mentah - hanya { id, title } |
Dalam mode penghematan trafik, tidak ada attributeValues pada hasil, jadi sempit sebelum membacanya - dengan bendera konfigurasi Anda sendiri, atau dengan bidang:
const found = await Pages.searchPage('cat');
if (Array.isArray(found) && found.length && 'attributeValues' in found[0]) {
// IPagesEntity[] — traficLimit is off
} else {
// IPageSearchResult[] — short cards
}
Perilaku runtime tidak berubah; hanya tipe yang dinyatakan sekarang mencerminkan kedua mode. Kartu pendek tidak membawa templateIdentifier, jadi tidak ada pencarian template yang dilakukan untuk mereka.
Halaman.searchPage(
nama*,
url,
langCode
);
Skema parameter
Skema
nama(diperlukan): string
Teks untuk mencari objek halaman (pencarian dilakukan pada bidang judul objek localizeInfos dengan bahasa yang diperhitungkan)
contoh: "Tentang Kami"
url: string
URL Halaman
contoh: "katalog"
langCode: string
Kode bahasa. Default: "en_US"
contoh: "en_US"
Contoh
Contoh minimal
const response = await Pages.searchPage('cup');
Contoh dengan atribut
const response = await Pages.searchPage('cup', 'en_US');
Contoh respons
[
{
"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
}
}
]
Skema respons
Skema: IPagesEntity[] | IPageSearchResult[]
id: number
Pengidentifikasi objek.
contoh: 8
parentId: number | null
Id halaman induk, jika mengandung null, maka itu adalah halaman tingkat atas.
contoh: 10
pageUrl: string
URL halaman yang unik.
contoh: "blog"
depth: number
Kedalaman nesting halaman relatif terhadap parentId.
contoh: 10
localizeInfos: ILocalizeInfo
Nama halaman, dengan mempertimbangkan lokalisasi.
contoh:
{
"title": "Blog",
"menuTitle": "Blog",
"htmlContent": "",
"plainContent": ""
}
isVisible: boolean
Tanda visibilitas halaman.
contoh: true
type: PageType
Tipe halaman.
contoh: "common_page"
templateIdentifier: string | null
Id pengguna dari template yang terhubung.
contoh: "template"
attributeSetIdentifier: string | null
Id set atribut.
contoh: "page"
attributeValues: IAttributeValues
Peta nilai atribut yang dikunci oleh penanda; objek kosong ketika tidak ada.
contoh:
{
"text": {
"type": "string",
"value": "some text",
"position": 0,
"additionalFields": []
}
}
isSync: boolean
Indikasi pengindeksan halaman.
contoh: true
template: object
Objek template.
contoh:
{}
position: number
Nomor item (untuk pengurutan).
contoh: 2
config: Record<string, number>
Pengaturan output untuk halaman katalog.
contoh:
{
"rowsPerPage": 1,
"productsPerRow": 1
}
products: number
Jumlah produk yang terhubung ke halaman.
contoh: 0
childrenCount: number
Jumlah anak.
contoh: 1
blocks: IBlockEntity[] | string[]
blok.
contoh:
{
"id": 4,
"attributeSetIdentifier": null,
"title": "Template",
"generalTypeId": 4,
"identifier": "template",
"version": 0,
"generalTypeName": "catalog_page",
"attributeValues": {},
"position": 1
}
blocks.attributeValues: IAttributeValues
Peta nilai atribut yang dikunci oleh penanda; objek kosong ketika tidak ada.
contoh:
{
"block-text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": [],
"isProductPreview": false
}
}
blocks.id: number
Pengidentifikasi unik blok.
contoh: 1234
blocks.localizeInfos: ILocalizeInfo
Informasi lokalisasi untuk blok.
contoh:
{
"key": "value"
}
blocks.version: number
Versi entitas blok.
contoh: 1
blocks.identifier: string
Pengidentifikasi string unik untuk blok.
contoh: "block1"
blocks.type: BlockType
Tipe blok.
contoh: "product"
blocks.position: number
Posisi blok untuk pengurutan.
contoh: 1
blocks.templateIdentifier: string | null
Pengidentifikasi untuk template yang digunakan oleh blok, atau null jika tidak berlaku.
contoh: "template1"
blocks.isVisible: boolean
Menunjukkan apakah blok terlihat.
contoh: true
blocks.countElementsPerRow: number
Jumlah elemen yang ditampilkan per baris di blok, jika berlaku.
contoh: 3
blocks.quantity: number
Jumlah item dalam blok, jika berlaku.
contoh: 5
blocks.similarProducts: IProductsResponse
Respons yang berisi produk serupa yang terkait dengan blok.
contoh:
{
"total": 10,
"items": []
}
blocks.products: IProductsEntity[]
Array entitas produk yang terkait dengan blok.
contoh:
[
{
"id": 1,
"name": "Product 1"
},
{
"id": 2,
"name": "Product 2"
}
]
moduleFormConfigs: Array<IFormConfig>
Konfigurasi formulir modul yang terhubung ke halaman.
rating: IRating
Data penilaian.
total: string
Jumlah total produk yang terhubung ke halaman.
contoh: "10"
categoryPath: string | null
String jalur kategori; null untuk halaman bersarang yang tidak memiliki jalur kategori sendiri.
contoh: "katalog"
distance: number
Jarak kosinus ke kueri. Hanya dikembalikan oleh endpoint pencarian semantik (vektor) ketika debug: true diteruskan dalam tubuh pencarian.
contoh: 0.12