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

getCategory

Get information about specific category from SAP Commerce Cloud.

This method receives data from the getCategories endpoint exposed by the SAP OCC API Catalogs Controller.

You can use this method to fetch information about a category available in the Catalog Version used by the current Base Store.

Signature

export declare function getCategory(
	context: SapccIntegrationContext,
	props: GetCategoryProps
): Promise<CategoryHierarchy>;

Parameters

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

Returns

Returns a representation of a Category Hierarchy.

Referenced Types

Examples

Fetching a category by id.

import { sdk } from '~/sdk';

const category = await sdk.commerce.getCategory({ id: 'collections' });

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

import { sdk } from '~/sdk';

const category = await sdk.commerce.getCategory({ id: 'collections', lang: 'en', currency: 'GBP' });

Fetching a category by id and selecting response fields.

import { sdk } from '~/sdk';

const category = await sdk.commerce.getCategory({ id: 'collections', fields: 'id,name,url' });

On this page