# Programmatically Create Product Categories?

**URL:** <https://forum.litium.com/t/programmatically-create-product-categories/305>\
**Category:** Questions\
**Created:** [October 22, 2018, 1:25pm UTC](https://forum.litium.com/t/programmatically-create-product-categories/305 "2018-10-22T13:25:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robin.w](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/robin.w/32/75_2.png) [@Robin.w](https://forum.litium.com/u/Robin.w)\
**Post date:** [October 22, 2018, 1:25pm UTC](https://forum.litium.com/t/programmatically-create-product-categories/305/1 "2018-10-22T13:25:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [October 22, 2018, 1:41pm UTC](https://forum.litium.com/t/programmatically-create-product-categories/305/2 "2018-10-22T13:41:17Z")

</div>

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;
```

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [October 22, 2018, 1:51pm UTC](https://forum.litium.com/t/programmatically-create-product-categories/305/3 "2018-10-22T13:51:56Z")

</div>

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