Programmatically Create Product Categories?

How do I create product categories from code? All I find in the documentation is what seem to be a method for creating Media Categories?

Litium version: 6.2

This is how i do it in a project, mabye it will help

var category = CategoryService.Get(categoryId);
        if (category == null)
        {
            category = new Category(categoryFieldTemplateSystemId, assortmentSystemId)
            {
                Id = categoryId,
                Localizations =
                {
                    [Locales.Language.svSE] = { Name = "svensk"}
                }
            }.MakeWritableClone();
            var se = new CultureInfo(Locales.Language.svSE);
            var urlSe = UrlSuggestionService.Suggest(se, 
            category.Localizations[Locales.Language.svSE].Name);
            category.Fields.AddOrUpdateValue(SystemFieldDefinitionConstants.Url, se, urlSe);

            category.ParentCategorySystemId = parentCategorySystemId;
            using (Solution.Instance.SystemToken.Use())
                CategoryService.Create(category);
        }

        return category;
1 Like

Some more examples can be found here: https://github.com/martenw/LitiumDemoHelper/blob/master/Services/CategoryDemoService.cs