Jump to content

Restrict menu items per customer groups


yiotaz

Recommended Posts

Hello,

 

I have a prestashop which restricts access to specific categories for certain user groups. While the category is restricted alright, the menu item that is linked to the category is not which is a bit confusing.

Does anyone now how I can also hide per user group specific menu items?

 

Thank you in advance,

Yiota

Link to comment
Share on other sites

Try changing line 599 (in PrestaShop v1.6.1.7) of modules/blocktopmenu/blocktopmenu.php from:

                $cat = new Category($category['id_category']);

to:

                $cat = new Category($category['id_category']);
                if (!$cat->checkAccess((int)$this->context->customer->id)) continue;

This should skip categories that the customer isn't allowed to access. I haven't tested this code, but I'd expect it to work.

Link to comment
Share on other sites

  • 2 years later...
On 9/18/2016 at 4:33 AM, rocky said:

Try changing line 599 (in PrestaShop v1.6.1.7) of modules/blocktopmenu/blocktopmenu.php from:


                $cat = new Category($category['id_category']);

to:


                $cat = new Category($category['id_category']);
                if (!$cat->checkAccess((int)$this->context->customer->id)) continue;

This should skip categories that the customer isn't allowed to access. I haven't tested this code, but I'd expect it to work.

Tried this solution in PrestaShop 1.7.4

The file is called modules/ps_mainmenu/ps_mainmenu.php search around line 717

Unfortunately there appears to be some caching in this file, so that the changes are only reflected after categories are updated.

This basically makes the proposed solution unworkable.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...