I have multi-website, multi-store magento installation. Each store have different root category.

I have created admin users for each store and restricted access to their related store.

In each admin panel product grid I have to display his product only.

So I want to filter each product before display in grid, To do this i need the root category id of current logged in admin.

But whenever I try to get current admin store root category, the value is zero.

So the questions are:

  1. How can I get currently logged in admin store's root category?
  2. How can I get each product root category?

Thanks in Advance..


What you are describing is no standard behaviour of magento, so depending on how this is all implemented, we might help you. Can you describe how the users are connected with the stores?

If you know the user, then you know the store.

Just to make sure we are talking about the Same things where:

Website ->    Store ->     StoreView (I'll use this naming)
because magento internally (on php class level) uses other terms:
Website -> Store Group -> Store

If you know the store, you can get directly the root category id: $store->getRootCategoryId().

If this return 0, then $store is admin. So you "only" need to get the correct store.

  • I am Using advance permission extenssion aitoc.com/en/magentomods_advanced_permissions.html ... So i can restrict the users to related store, I am try to get store_id but I can't get it, I need to fetch the store_id based on user logged in.. – Charlie May 27 '14 at 10:21
  • No idea about this extension and magento.se is not for third party support. Check the code of the extension how the user is connected to the store and get THIS store. – Fabian Blechschmidt May 27 '14 at 10:22

Fabian is right, you have to provide the correct store, because by default it is admin. The search engines are throwing out this result:


which is not good enough for you, because you will have to provide the store's code also:


The default store's code is default, but if you are not sure about your store's codes just have a look at core_store table in your database, you will find the store codes in the code column.


in magento 2 use below method


//get root category id

echo $storeManager->getStore()->getRootCategoryId();

Your Answer

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

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