So, I'm writing a plugin to assist with a content migration which will be creating new category groups. I'm able to successfully run the plugin, and what's strange is that the category group does get saved to the site's config in the database, however the category group itself never shows up in the categorygroups database table.

We have disabled the use of the project.yaml file in the config/general.php file.

$siteId = Craft::$app->sites->getPrimarySite()->id;

$group = new CategoryGroup([
    'name' => 'Test Category Group',
    'handle' => 'testCategoryGroup'

$siteSettings = new CategoryGroup_SiteSettings([
    'siteId' => $siteId,

$group->setSiteSettings(array($siteId => $siteSettings));

if (!Craft::$app->getCategories()->saveGroup($group)) {


Craft::$app->getSession()->setNotice(Craft::t('app', 'Category group saved: ' . $groupName));

I do not receive any validation errors, and as I said, if I look in the database's info table in the config column, the category group exists there. However it just never actually gets created.

For a little more context, currently this is the only thing running in the plugin, in the init method which I'll move out once I can get this working.

Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.