Generate category codes

Summary

Category Code Generator overview

The Category Code Generator in Akeneo PIM automates the generation of category codes during the creation of new categories. Instead of entering a code manually, you configure a generator that builds the code from a configurable template combining static text, auto-incrementing numbers, and values derived from the root category.

With the Category Code Generator, you can:

  • Define the structure of category codes using different property types
  • Target specific category trees for code generation
  • Manage custom abbreviations (nomenclature) for each root category

Before you start

Permissions

The Category Generators permission lives under the Generators section in Settings > Roles. Two levels are available: View lets a user see the list of generators and consult each one's settings, and Manage gives full rights to create, edit, and delete generators, and to edit the nomenclature. By default, users have the View permission; an Administrator can grant Manage or remove access entirely.

 

Create a Category Code Generator

  1. Go to Settings > Generators and select the Category Generators tab.
  2. Click Create. If you don't see this tab or the Create button, check with your Administrator that you have the appropriate permissions.
  3. In the modal window, fill in a label and a code. The label must not exceed 255 characters. The code must be unique, alphanumeric (underscores allowed), and no longer than 100 characters; it is auto-filled from the label but can be modified manually.
  4. Confirm to open the full editor, organized into three tabs: General Properties, Selection, and Structure.

Once you save a generator, it is active immediately: a code is generated automatically every time a new category is created in the targeted category trees, as long as no code is provided manually.

One generator per category tree. Each category tree can only be covered by a single generator. The Create button is disabled once all category trees are assigned to a generator.

 

General Properties tab

In the General Properties tab, you can view the generator code (read-only after creation), set the text transformation applied to the generated code, and add label translations for each of your UI locales.

  • No transformation: the code is generated as-is (for example, Print_CAT_0001)
  • Uppercase: the code is fully uppercased (for example, PRINT_CAT_0001)
  • Lowercase: the code is fully lowercased (for example, print_cat_0001)

Selection tab

In the Selection tab, you define which category trees the generator applies to. Select one or more specific category trees, or choose All category trees to apply the generator to every tree not already assigned to another generator.

Selecting All category trees is only available if no other generator already covers all trees. Once one generator covers all trees, the option is no longer available for new generators.

 

The screenshot above shows the Selection tab, with a category tree selector that allows choosing one or more specific trees or the All category trees option.

Define the structure

In the Structure tab, create the template applied when generating a category code. Click Add new property to add one or more properties to the structure, for up to 20 properties. Properties can be reordered by drag and drop.

The screenshot above shows the Structure tab with a list of configured properties (Free text, Auto number, Category tree) and a live preview of the generated code at the top.

Free text

  • Inserts a static text string in the code.
  • Must not be blank and must not exceed 50 characters. Leading or trailing spaces are not accepted.
  • You can add multiple Free text properties.

Auto number

  • Inserts an auto-incrementing number.
  • Minimum digits: sets the minimum length of the number, padding with leading zeros when needed. For example, if set to 4, the number 5 is rendered as 0005. Accepts values between 1 and 15.
  • Minimum number: the starting value for the sequence. For example, if set to 100, the first generated code includes 0100 (assuming 4 minimum digits).

Your structure can contain only one Auto number property.

 

The Auto number always uses the value one higher than the last number ever generated for the same prefix. Deleting a category does not reset the sequence. To fully reset it, delete both the category and the generator, then create a new generator.

 

Category tree (root category code)

Inserts a value derived from the root category code of the category being created. Three formats are available:

  • Category tree code: uses the full root category code as-is.
  • Category tree code (first characters): uses only the first N characters of the root category code. Configure the operator (Is equal to (=) or Lower than or equal to (≤)) and the number of characters (between 1 and 5).
  • Category tree code (with nomenclature): uses a custom abbreviation you define for each root category. See Nomenclature: custom abbreviations for root categories below.

Delimiter

By default, no delimiter is added between properties. Tick Use delimiters between each property to activate it. The only accepted delimiter is _ (underscore).

Nomenclature: custom abbreviations for root categories

When you choose the Category tree code (with nomenclature) format for the Category tree property, you can define a custom short code for each of your root categories. This is useful when root category codes are long or inconsistent.

To edit the nomenclature, click Edit nomenclature in the property settings panel. A modal window opens with two sections:

The screenshot above shows the Category Nomenclature modal with a Global Rules section at the top (operator and character count settings) and a Category Nomenclatures table listing each root category with its abbreviation field.

Global rules

Set the operator and number of characters that apply by default to all root categories:

  • = (Is equal to): the abbreviation must contain exactly N characters. Root category codes shorter than N produce a validation error and must be corrected before saving.
  • ≤ (Lower than or equal to): the abbreviation can contain at most N characters. This is more permissive and works well when some root category codes are shorter than others.

The number of characters must be between 1 and 5.

You can also tick Generate if no mapping found: if a root category has no nomenclature value defined, the system automatically falls back to the first N characters of its code.

Category nomenclatures

The table lists all your root categories with their label, code, and a field to enter the abbreviation. If Generate if no mapping found is enabled, an auto-generated placeholder is shown. You can search categories by label or code if you have more than 5 root categories.

Nomenclature values are shared across all your Category Code Generators. Changing them in one generator affects every generator that uses the Category tree code (with nomenclature) format.

 

Live preview

A live preview of the generated code is shown at the top of the Structure tab, reflecting your current configuration. It updates automatically as you add, remove, or modify properties, and respects the text transformation set in the General Properties tab.

When is a category code generated

  • A code is generated only when a new category is created and no code is provided manually.
  • If a category already has a code, the generator never overwrites it.
  • Generation is triggered through the Akeneo PIM user interface, an import, or the API.

Existing categories are not updated when a generator is created or modified. Only newly created categories receive an automatically generated code.

 

Edit or delete a Category Code Generator

Modifying or deleting a generator has no impact on codes already generated: all existing category codes remain unchanged. Only categories created after the change are affected.

  1. Go to Settings > Generators > Category Generators.
  2. Click a generator in the list to edit it, or click Delete to remove it.
  3. Confirm the deletion when prompted.