Categories
This section will cover the basics of the categories and how to fetch them
API Reference
You can find all available Bloomreach Discovery module methods and their description in the API Reference.
Fetching categories
To fetch categories, you can use the findCategories method.
import { sdk } from '~/sdk'
const categories = await sdk.brs.findCategories()
Fetching by id
To fetch a category by id, you can use the findCategoryById method.
import { sdk } from '~/sdk'
const id = 'PNB160400000000'
const category = await sdk.brd.findCategoryById({ id })
Fetching by slug
To fetch a category by slug, you can use the findCategoryBySlug method.
import { sdk } from '~/sdk'
const slug = 'some-slug'
const category = await sdk.brd.findCategoryBySlug({ slug })
Specifying fields
Each of the methods above allows to specify the fields that should be returned. To do so, define the expect
property.
import { sdk } from '~/sdk'
const categories = await sdk.brd.findCategories({
expect: `
displayName
id
`,
})
Query hints
Each of the methods above allows to specify the query hints that should be used. To do so, define the queryHints
property.
const categories = await sdk.brd.findCategories({
queryHint: {
brUid2: 'some value',
},
})