I want to set the root category of a new batch created store.

I'm looking for something like :


But it looks like it does not exists, despite there is a $store->getRootCategory() method.

I found a method in the Category Model: $category->setStoreId($storeId) but since a Category may be used by several stores as root category, it's probably not the right way do it ? is it ?

I'm a bit lost on that case, any help would be appreciated !

1 Answer 1


The root category ID is in the 'store group' entity. Try this:

    $group = $store->getGroup();
    try {
    }catch (\Exception $e) {

  • In case it helps : since it was for a newly created store, I needed to create a new group instead of getting it with $store->getGroup(); which in this case, just return false
    – Gael COAT
    Commented Aug 28, 2016 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.