getCatalogVersion
Method fetching a specific Catalog Version that exists in the current Base Store in SAP Commerce Cloud.
This method sends a GET request to the getCatalogVersion endpoint of the Alokai Middleware. In turn, it receives data from the getCatalogVersion endpoint exposed by the SAP OCC API Catalogs Controller.
This method does not accept arguments such as catalogVersionId or catalogId. The API Middleware derives them automatically from the sapcc configuration in middleware.config.js before sending the request to OCC API. Thus, the method only allows fetching the currently used Catalog Version.
The returned object contains (among others) information about category hierarchies defined for the Catalog Version. It can be used to build navigation components.
Signature
export declare function getCatalogVersion<Res extends CatalogVersion = CatalogVersion,
Props extends BaseProps = BaseProps>(
props?: Props,
options?: MethodOptions
): Promise<Res>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Optional | Props | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
options | Optional | MethodOptions | Options that can be passed to additionally configure the request or customize the logic in a plugin. |
Returns
Returns a representation of a Catalog Version.
Referenced Types
Examples
Fetching a CatalogVersion and extracting categories from it.
import { sdk } from '~/sdk';
const { categories = [] } = await sdk.commerce.getCatalogVersion();Using the method the way it will be possible to cache the response.
import { sdk } from '~/sdk';
const { categories = [] } = await sdk.commerce.getCatalogVersion({ lang: 'en', currency: 'GBP' });Fetching a CatalogVersion with a selected subset of fields.
import { sdk } from '~/sdk';
const { categories = [] } = await sdk.commerce.getCategory({ fields: 'categories(id,name,url)' });