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

getSearchSuggestions

Get list of available search suggestions from SAP Commerce Cloud.

This method receives data from the getSuggestions endpoint exposed by the SAP OCC API Products Controller.

Signature

export declare function getSearchSuggestions(
	context: SapccIntegrationContext,
	props: SearchSuggestionsProps
): Promise<SuggestionList>;

Parameters

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

Returns

Returns a representation of a Suggestion List.

Referenced Types

Examples

Fetching suggestions for a specific searchTerm.

import { sdk } from '~/sdk';

const suggestions = await sdk.commerce.getSearchSuggestions({ searchTerm: 'shirt' });

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

import { sdk } from '~/sdk';

const suggestions = await sdk.commerce.getSearchSuggestions({ searchTerm: 'shirt', lang: 'en', currency: 'GBP' });

Limiting the number of search suggestions by using the max parameter.

import { sdk } from '~/sdk';

const suggestions = await sdk.commerce.getSearchSuggestions({ searchTerm: 'shirt', max: 3 });

On this page