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

getProductsByIds

Fetch details of a list of products from SAP Commerce Cloud.

This method sends a GET request to the getProductsByIds endpoint of the Alokai Middleware. In turn, it receives data from the getProductsByIds endpoint exposed by the SAP OCC API Alokai Products Controller.

Signature

export declare function getProductsByIds<Res extends SimpleProductList = SimpleProductList,
	Props extends ProductsByIdsProps = ProductsByIdsProps>(
	props: Props,
	options?: MethodOptions
): Promise<Res>;

Parameters

NameRequiredTypeDescription
propsRequiredPropsParameter 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 a representation of a list of Products.

Referenced Types

Examples

Fetching products by their IDs (passed as the ids parameter).

import { sdk } from '~/sdk';

const products = await sdk.commerce.getProductsByIds({ ids: ['1992695', '4392695'] });

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

import { sdk } from '~/sdk';

const products = await sdk.commerce.getProductsByIds({ ids: ['1992695', '4392695'], lang: 'en', currency: 'GBP'  }); * 
```

On this page