Alokai
You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x

getProductSearchPageData

Method allowing to fetch combined product and catalog data for product listing pages.

This method sends a GET request to the getProductSearchPageData endpoint of the Alokai Middleware. It composes responses from two other endpoints: searchProduct and getCatalogVersion. In turn, it receives data from two endpoints exposed by the SAP OCC API: getProducts and getCatalogVersion.

Signature

export declare function getProductSearchPageData<Res extends ProductSearchPageData = ProductSearchPageData,
	Props extends GetProductSearchPageDataProps = GetProductSearchPageDataProps>(
	props?: Props,
	options?: MethodOptions
): Promise<Res>;

Parameters

NameRequiredTypeDescription
propsOptionalPropsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.
optionsOptionalMethodOptionsOptions that can be passed to additionally configure the request or customize the logic in a plugin.

Returns

Returns composed sources for Product Search results page.

Referenced Types

Examples

Using the method without any parameters to fetch Product Search Page data (with unfiltered products) and the current Catalog Version.

import { sdk } from '~/sdk';

const searchPageData = await sdk.commerce.getProductSearchPageData();

Using the method the way it will be possible to cache the response.

import { sdk } from '~/sdk';

const searchPageData = await sdk.commerce.getProductSearchPageData({ lang: 'en', currency: 'GBP' });

Using the method with parameters for the searchProduct endpoint. Refer to the ProductSearchProps interface to learn about possible properties.

import { sdk } from '~/sdk';

const searchPageData = await sdk.commerce.getProductSearchPageData({
 search: { searchTerm: 'shirt' }
});

Using the method with parameters for the getCatalogVersion endpoint. Refer to the BaseProps interface to learn about possible properties.

import { sdk } from '~/sdk';

const searchPageData = await sdk.commerce.getProductSearchPageData({
 catalog: { fields: 'categories(id,name,url)' }
});

Using the method with parameters for both searchProduct and getCatalogVersion endpoints simultaneously.

import { sdk } from '~/sdk';

const searchPageData = await sdk.commerce.getProductSearchPageData({
  search: { fields: 'freeTextSearch' },
  catalog: { fields: 'categories(id,name,url)' }
});

On this page