---
title: Customizing how products are categorized in the Strands integration
related:
  - https://docs.kentico.com/k81/integrating-3rd-party-systems/strands-recommender-integration.md
  - https://docs.kentico.com/k81/custom-development/loading-custom-classes-from-app_code.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 for categorizing products in the Strands integration — both in the Strands catalog feed and the [Strands recommendations web part](https://docs.kentico.com/k81/integrating-3rd-party-systems/strands-recommender-integration/placing-strands-recommendations-on-a-page.md). To fully customize the categorization on both the 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 you can create a custom class in which you perform such a customization. The page also provides two example customizations for you to build on.

## Creating a custom Strands product categorization

1. Open your web project in Visual Studio and create a new class in the **App\_Code** folder (or **CMSApp\_AppCode -> Old\_App\_Code** if the project is installed as a web application). For example, name the class _**CustomStrandsCatalogCategoryMapper.cs**_.
2. Copy the following code into the class:

   ```csharp

   using System;
   using System.Globalization;

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

   [CustomStrandsCategoryMappingAttribute]
   public partial class CMSModuleLoader
   {
       private class CustomStrandsCategoryMappingAttribute : CMSLoaderAttribute
       {
           private class CustomStrandsCatalogCategoryMapper : IStrandsCatalogCategoryMapper
           {
               public string GetItemCategory(TreeNode catalogItem)
               {
                   // Body of your Strands catalog categorization customization method
               }
           }

           /// <summary>
           /// Registers module methods.
           /// </summary>
           public override void Init()
           {
               ObjectFactory<IStrandsCatalogCategoryMapper>.SetDefaultObjectTypeTo<CustomStrandsCatalogCategoryMapper>();
           }
       }
   }

   ```

   Now that you have the structure of the _**CustomStrandsCatalogCategoryMapper**_ class, you can create your own customization of the Strands catalog feed customization.
3. Customize 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);
      }

      ```
4. Once you have customized the _GetItemCategory_ method, **Save** the class file, build your solution, and view your Strands catalog feed. You should see the system categorizing products in the feed according to the new customization.

   1. **Note** that you can view your Strands catalog feed at _http://www.yoursite.com/CMSModules/StrandsRecommender/CMSPages/StrandsCatalogFeed.ashx._
   2. The same categorization is now used in the [Strands recommendations web part](https://docs.kentico.com/k81/integrating-3rd-party-systems/strands-recommender-integration/placing-strands-recommendations-on-a-page.md) in the **Category** recommendation type.

> **Info:** **Further customization**
>
> You can create any implementation of the _IStrandsCatalogCategoryMapper_ interface and register it in the system using the _ObjectFactory_ class' _SetDefaultObjectTypeTo_ method. 
