---
title: Customizing how products are categorized in the Strands integration
related:
  - https://docs.kentico.com/k12sp/integrating-3rd-party-systems/strands-recommender-integration.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

By default, Kentico uses page type IDs to categorize products in the Strands integration – both in the Strands catalog feed and the [Strands recommendations web part](https://docs.kentico.com/k12sp/integrating-3rd-party-systems/strands-recommender-integration/placing-strands-recommendations-on-a-page.md). To fully customize the categorization in both places, you need to create a custom implementation of the **IStrandsCatalogCategoryMapper** interface. By customizing the categorization, you can have it better represent the structure of your site.

This page describes how to create a custom class in which you perform such a customization. The page also provides two sample customizations for you to build on.

## Implementing custom Strands product categorization

1. Open your Kentico web project in Visual Studio (using the **WebSite.sln** or **WebApp.sln** file).
2. Create a new class, for example named _**CustomStrandsCatalogCategoryMapper.cs**_.

   - Either add the class into a custom code library project within the Kentico solution (recommended) or directly into the Kentico web project (into a custom folder under the **CMSApp** project for _web application_ installations, into the **App\_Code** folder for _web site_ installations).

     > **Info:** When using a custom project (assembly), you need to perform the following steps to ensure that the system can detect your custom interface implementations:
     >
     > 1. Edit your custom assembly's **AssemblyInfo.cs** file (in the _Properties_ folder).
     > 2. Add the **AssemblyDiscoverable** assembly attribute (requires a reference to _CMS.Core.dll_):
     >
     >    ```csharp
     >
     >    using CMS;
     >
     >    [assembly:AssemblyDiscoverable]
     >
     >    ```
     > 3. Save the file and **Build** the custom project.
3. Make the class implement the **IStrandsCatalogCategoryMapper** interface:

   ```csharp

   using System;
   using System.Globalization;

   using CMS;
   using CMS.Core;
   using CMS.StrandsRecommender;
   using CMS.DocumentEngine;
   using CMS.Ecommerce;

   // Registers the custom IStrandsCatalogCategoryMapper implementation
   [assembly: RegisterImplementation(typeof(IStrandsCatalogCategoryMapper), typeof(CustomStrandsCatalogCategoryMapper))]

   public class CustomStrandsCatalogCategoryMapper : IStrandsCatalogCategoryMapper
   {
       public string GetItemCategory(TreeNode catalogItem)
       {
           // Body of your Strands catalog categorization customization method
       }
   }

   ```
4. Add a custom implementation for the **GetItemCategory** method, as described in one of the following examples:

   1. **Using an SKU department ID as the category field in the Strands catalog feed**

      ```csharp

      /// <summary>
      /// Retrieves SKUDepartmentID which will be used for categorizing the page in the Strands integration.
      /// </summary>
      /// <param name="catalogItem">Document</param>
      /// <returns>Category field</returns>
      public string GetItemCategory(TreeNode catalogItem)
      {
          SKUInfo skuInfo = SKUInfoProvider.GetSKUInfo(catalogItem.NodeSKUID);
          if (skuInfo != null)
          {
              return skuInfo.SKUDepartmentID.ToString(CultureInfo.InvariantCulture);
          }
          throw new Exception("[CustomStrandsCategoryCatalogMapper.GetItemCategory]: SKUInfo was not found for specified TreeNode.");
      }

      ```
   2. **Using the path to the page as the category field in the Strands catalog feed**

      ```csharp

      /// <summary>
      /// Retrieves the path to the page, excluding the page's name. The path will be used for categorizing the page in the Strands integration.
      /// </summary>
      /// <param name="catalogItem">Document</param>
      /// <returns>Category field</returns>
      public string GetItemCategory(TreeNode catalogItem)
      {
          string docName = catalogItem.DocumentName;
          string docNamePath = catalogItem.DocumentNamePath;

          return docNamePath.Substring(0, docNamePath.Length - docName.Length);
      }

      ```
5. **Save** the class file and build your solution.

Now that you have customized the _GetItemCategory_ method, view your Strands catalog feed. You should see the system categorizing products in the feed according to the new customization.

- You can view your Strands catalog feed at: _\~/CMSModules/StrandsRecommender/CMSPages/StrandsCatalogFeed.ashx_
- The same categorization is now used in the [Strands recommendations web part](https://docs.kentico.com/k12sp/integrating-3rd-party-systems/strands-recommender-integration/placing-strands-recommendations-on-a-page.md) in the **Category** recommendation type.
