getCatalogVersion
Fetch specific Catalog Version that exists in the current Base Store in SAP Commerce Cloud.
This method 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(
context: SapccIntegrationContext,
props?: BaseProps
): Promise<CatalogVersion>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | SapccIntegrationContext | |
props | Optional | BaseProps | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
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)' });