Edit in GitHubLog an issue

Implement categories on the storefront

Use the following API operations to manage categories for Commerce projects that use the Merchandising Services composable catalog data model:

  • Create category data using the categories operations available in the Data Ingestion REST API, and using the products operations to manage product category assignments.

  • Retrieve category navigation and hierarchy data using the navigation and categoryTree queries available in the Merchandising Services GraphQL API.

  • Retrieve category context for products — such as breadcrumbs — using the categories field on product queries in the Merchandising Services GraphQL API.

Category types

The navigation query, categoryTree query, and categories field on product queries each return a different category type, optimized for its specific use case. All three types implement the CategoryViewV2 interface, which defines the two required fields shared by every category: slug and name. For complete field details, see CategoryViewV2 in the Merchandising Services GraphQL API reference.

  1. CategoryNavigationView — For menu rendering and navigation
  2. CategoryProductView — For category data returned with product queries
  3. CategoryTreeView — For hierarchical category management and rich category pages

CategoryNavigationView type

The CategoryNavigationView type implements CategoryViewV2 and provides category data optimized for storefront navigation. It contains:

  • name and slug — Category identity
  • children — Nested subcategories for building the full menu hierarchy in a single query

Use this type to render top menus, dropdowns, and mobile navigation.

Type definition

Copied to your clipboard
type CategoryNavigationView implements CategoryViewV2 {
slug: String!
name: String!
children: [CategoryNavigationView]
}

For complete field details, see [CategoryNavigationView](https://developer.adobe.com/commerce/webapi/graphql/merchandising/#definition-CategoryNavigationView) in the Merchandising Services GraphQL API reference.

See the Navigation query examples section for example queries and responses using this type.

CategoryProductView type

The CategoryProductView type implements CategoryViewV2 and provides category data within product query responses. Each product's categories field returns a list of CategoryProductView objects containing:

  • name and slug — Category identity
  • level — Position in the hierarchy
  • parents — Full chain of ancestor categories

Use this type to render breadcrumbs, filter by category, or display category context on product detail pages.

Type definition

Copied to your clipboard
type CategoryProductView implements CategoryViewV2 {
name: String!
slug: String!
level: Int!
parents: [CategoryProductView!]
}

The parents field is self-referencing—each parent entry is itself a CategoryProductView with its own name, slug, level, and parents. This allows you to reconstruct the full breadcrumb path for any category a product belongs to.

For complete field details, see CategoryProductView in the Merchandising Services GraphQL API reference.

See the Products query with categories examples section for example queries and responses using this type.

CategoryTreeView type

The CategoryTreeView type implements CategoryViewV2 and provides the richest category data. It contains:

  • name and slug — Category identity
  • level and parentSlug / childrenSlugs — Hierarchy and relationships
  • description — Category descriptive content
  • metaTags — SEO metadata (title, description, keywords)
  • images — Category images

Use this type for rich category landing pages, SEO-driven content, and CMS administration.

Type definition

Copied to your clipboard
type CategoryTreeView implements CategoryViewV2 {
slug: String!
name: String!
level: Int
parentSlug: String
childrenSlugs: [String]
description: String
metaTags: CategoryMetaTags
images: [CategoryImage]
}
type CategoryMetaTags {
title: String
description: String
keywords: [String]
}
type CategoryImage {
url: String!
label: String
roles: [String]
customRoles: [String]
}

For complete field details, including the CategoryMetaTags and CategoryImage types, see CategoryTreeView in the Merchandising Services GraphQL API reference.

See the CategoryTree query examples section for example queries and responses using this type.

Limitations and considerations

Choose the right query for the use case

  • Use the navigation query for storefront menus. It is heavily cached, limited to four levels, and returns only the lightweight fields needed for rendering.
  • Use the categoryTree query when you need full hierarchy metadata, descriptions, images, or SEO fields.
  • Use the categories field on product queries only when category context (such as breadcrumbs) is needed on a product page. Omit it when it is not needed to avoid unnecessary overhead.

The navigation query returns a maximum of four levels of nested categories. Nesting children beyond four levels in your query returns no additional data. Design your category hierarchy and query depth accordingly.

categoryTree discovery-first behavior

When slugs is omitted from a categoryTree query, the depth parameter is ignored and only root-level (level 1) categories are returned. This is by design — the query uses a discovery-first pattern that lets clients find category tree entry points before fetching subtrees. To retrieve descendants, always pass slugs along with the desired depth.

Optional fields add overhead

The description, metaTags, and images fields on categoryTree are optional. Exclude them when building navigation or hierarchy views that do not need descriptive content or SEO metadata.

Limit categoryTree depth

Pass the depth parameter to categoryTree to avoid fetching deeper levels than you need.

Target specific subtrees

Pass the slugs parameter to categoryTree to fetch only the branches you need rather than the entire tree.

The navigation query signature:

Copied to your clipboard
type Query {
navigation(family: String!): [CategoryNavigationView]
}

The family parameter is required and specifies which category family to retrieve. The query returns the full hierarchy for that family in a single request.

Retrieve basic top menu navigation

Copied to your clipboard
query GetTopMenuNavigation {
navigation(family: "top-menu") {
slug
name
children {
slug
name
children {
slug
name
}
}
}
}

The response returns a single root node with no nested children:

Copied to your clipboard
Men clothing
└── (no children)

Retrieve multi-level menu navigation

Copied to your clipboard
query GetFullMenuNavigation {
navigation(family: "menu") {
slug
name
children {
slug
name
children {
slug
name
children {
slug
name
}
}
}
}
}

The response returns a three-level nested hierarchy:

Copied to your clipboard
Men clothing
└── Men tops
└── Jackets

Products query with categories examples

Copied to your clipboard
type ProductView {
categories(family: String): [CategoryProductView]
}

The categories field is available on product types such as ProductView. Use the optional family parameter to return only categories from a specific category family. When omitted, categories from all families are returned.

Retrieve product categories with breadcrumb ancestors

Copied to your clipboard
query {
products(skus: ["shorts-red-m"]) {
name
sku
categories(family: "clothing") {
name
slug
level
parents {
name
slug
level
}
}
}
}

The parents array provides the full ancestor chain, which you can use to render a breadcrumb path:

Copied to your clipboard
Men (level 1) → Clothes (level 2) → Shorts (level 3)
└── product: Red Shorts (M)

Filter product categories by family

A product can belong to categories in multiple families. Use the family parameter to return only categories from a specific family. In this example, the product belongs to categories in both the "clothing" and "seasonal" families, but the query filters for "seasonal" only.

Copied to your clipboard
query {
products(skus: ["shorts-red-m"]) {
name
sku
categories(family: "seasonal") {
name
slug
level
parents {
name
slug
level
}
}
}
}

Without the family filter, the response would include categories from all families the product belongs to—for example, both "Shorts" from the "clothing" family and "Summer Essentials" from the "seasonal" family. The family parameter narrows the result to a single family, which is useful when rendering context-specific navigation or breadcrumbs.

CategoryTree query examples

The categoryTree query signature:

Copied to your clipboard
type Query {
categoryTree(family: String!, slugs: [String!], depth: Int): [CategoryTreeView]
}

Retrieve root-level categories

When called without slugs, the query returns only root-level categories. See categoryTree discovery-first behavior for details.

Copied to your clipboard
query GetRootCategories {
categoryTree(family: "main-catalog") {
slug
name
level
parentSlug
childrenSlugs
}
}

The flat list represents the root-level categories and their immediate children.

Copied to your clipboard
Men's Category (level 1)
└── Men's Clothing (level 2)
Women's Category (level 1)
└── Women's Clothing (level 2)

Retrieve specific category subtree

Copied to your clipboard
query GetSpecificCategorySubtree {
categoryTree(
family: "main-catalog"
slugs: ["men/clothing", "women/clothing"]
depth: 2
) {
slug
name
level
parentSlug
childrenSlugs
}
}

The depth parameter counts levels relative to the specified starting slugs, while the level field reflects each category's absolute position in the hierarchy based on its slug path.

Copied to your clipboard
Men's Clothing (level 2) Women's Clothing (level 2)
├── Men's Tops (level 3) ├── Women's Tops (level 3)
└── Men's Bottoms (level 3) └── Women's Bottoms (level 3)

Retrieve category details with metadata and images

Use the description, metaTags, and images fields to build rich category landing pages that include SEO metadata and visual content. This is especially useful when rendering a category page that needs a hero image, descriptive copy, and proper <meta> tags for search engines.

Copied to your clipboard
query CategoryTree {
categoryTree(slugs: ["men/clothes/shorts"], family: "clothing") {
slug
name
level
parentSlug
childrenSlugs
description
metaTags {
title
description
keywords
}
images {
url
label
roles
customRoles
}
}
}

Query quick reference

Use caseQueryType
Storefront menus, dropdowns, mobile navigation
navigation
CategoryNavigationView
Category landing pages with SEO metadata and images
categoryTree
CategoryTreeView
Breadcrumbs and category context on product pages
products (categories field)
CategoryProductView
Category hierarchy management and CMS administration
categoryTree
CategoryTreeView
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2026 Adobe. All rights reserved.