---
title: Categorizations
slug: commerce-connect-14/docs/categorizations
docTags: 
createdAt: 2026-07-23T10:25:34.040Z
---

Categorizations are represented by the `EPiServer.Commerce.Catalog.Linking.NodeRelation` class and administered using the `EPiServer.Commerce.Catalog.Linking.IRelationRepository` service.

The `Parent` property of the `NodeRelation` contains the `ContentReference` of the category. You can categorize each entry and category. The class also has a `SortOrder` property that describes the order of the categorizations.

A `NodeRelation` is uniquely defined by the `ContentReference` in its `Parent` and `Child` property (referencing the categorized item). You cannot add the same categorization more than once to an entry or another category.

**\[New in 11.2.0]**

For categorizations of entries, you can work with the `NodeEntryRelation` type instead of the `NodeRelation` type. `NodeEntryRelation` derives from `NodeRelation` and exposes the additional `IsPrimary` property, describing whether the relation is the primary categorization for the entry.

While each entry can have multiple categorizations linking it to several categories, only one can be the primary relation. The primary relation specifies the entry's primary or *home* category. This category is used when building the entry's default hierarchical URL.

## Get the categorizations of an entry or category

To get categorizations, call the `GetChildren` method of `IRelationRepository` with the `ContentReference` of an entry or category.

```csharp
public IEnumerable<NodeRelation> ListCategories(ContentReference referenceToEntryOrCategory)
      {
        var relationRepository = ServiceLocator.Current.GetInstance<IRelationRepository>();
        var categories = relationRepository.GetChildren<NodeRelation>(referenceToEntryOrCategory);
        return categories;
      }
```

### Add a categorization to an entry or category

To add `NodeRelation` objects to an entry or category, use the `UpdateRelations` method or `UpdateRelation` extension method of `IRelationRepository`. The new categorization must have a `Parent ContentReference` and a `Child ContentReference`.

```csharp
public void AddCategory(ContentReference referenceToEntryOrCategory, ContentReference referenceToCategory)
      {
        var relationRepository = ServiceLocator.Current.GetInstance<IRelationRepository>();
        var newCategory = new NodeRelation
          {
            SortOrder = 100,
            Child = referenceToEntryOrCategory,
            Parent = referenceToCategory
          };
        relationRepository.UpdateRelation(newCategory);
      }
```

### Remove a categorization from an entry or category

To remove a categorization, call the `RemoveRelations` method or `RemoveRelation` extension method of `IRelationRepository` with a `NodeRelation` object matching an existing categorization. You can construct a matching object, or use `GetChildren` or `GetParents` to get the existing `Relations`, filter out the object you want to remove, and pass it to `RemoveRelation`.

```text
public void RemoveCategory(ContentReference referenceToEntryOrCategory, ContentReference referenceToCategory)
      {
        var relationRepository = ServiceLocator.Current.GetInstance<IRelationRepository>();
        // Define a relation matching the one to remove, or use
        // GetRelations to find the one you want to remove and pass that to
        // RemoveRelation
        var relationToRemove = new NodeRelation
          {
            Child = referenceToEntryOrCategory,
            Parent = referenceToCategory
          };
        // Removes matching NodeRelation, or no action if no match exists
        relationRepository.RemoveRelation(relationToRemove);
      }
```
