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

getProductSearchPageData

Fetch combined product and catalog data for product listing pages.

This method receives data from two endpoints exposed by the SAP OCC API: getProducts and getCatalogVersion.

Signature

export declare function getProductSearchPageData(
	context: SapccIntegrationContext,
	props?: GetProductSearchPageDataProps
): Promise<ProductSearchPageData>;

Parameters

NameRequiredTypeDescription
contextRequiredSapccIntegrationContext
propsOptionalGetProductSearchPageDataPropsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.

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.

import { sdk } from '~/sdk';

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

Using the method with parameters for the getCatalogVersion endpoint.

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