Jump to content

Invisible Categories in top menu


Christos Sar

Recommended Posts

Hello guys

 

I have a problem and i can't find a solution..I own an e-shop and i want to make some categories from the top horizontical menu, invisible for a user group...Not just inaccessible, but invisible..Do you know if this is possible to happen?

 

Thanks in advance

Link to comment
Share on other sites

Unfortunately, it's not so easy, since the code is generated inside the PHP file instead of in the TPL file. You'll need to change line 597 of modules/blocktopmenu/blocktopmenu.php from:

        foreach ($categories as $key => $category) {

to:

        foreach ($categories as $key => $category) {
            if ($category['id_category'] == 7 || $category['id_category'] == 8) continue;

Change 7 and 8 to the categories you want hidden. Add more if necessary.

 

I haven't tested this code, but I expect it to work.

Link to comment
Share on other sites

Unfortunately, it's not so easy, since the code is generated inside the PHP file instead of in the TPL file. You'll need to change line 597 of modules/blocktopmenu/blocktopmenu.php from:

        foreach ($categories as $key => $category) {

to:

        foreach ($categories as $key => $category) {
            if ($category['id_category'] == 7 || $category['id_category'] == 8) continue;

Change 7 and 8 to the categories you want hidden. Add more if necessary.

 

I haven't tested this code, but I expect it to work.

Rocky thank you for your advice, but I don't want to hide these categories from all the visitors or customers of the shop, but only from an exact group of customers that i have made..do I have to add something else?

Link to comment
Share on other sites

In that case, you'll need to add additional code:

        $hide_categories = false;
        
        foreach ($this->context->customer->getGroups() as $group) {
            if ($group == 2) {
                $hide_categories = true;
                break;
            }
        }

        foreach ($categories as $key => $category) {
            if ($hide_categories && ($category['id_category'] == 7 || $category['id_category'] == 8)) continue;

Change 2 to the ID of the customer group you want to hide the categories from.

Link to comment
Share on other sites

In that case, you'll need to add additional code:

        $hide_categories = false;
        
        foreach ($this->context->customer->getGroups() as $group) {
            if ($group == 2) {
                $hide_categories = true;
                break;
            }
        }

        foreach ($categories as $key => $category) {
            if ($hide_categories && ($category['id_category'] == 7 || $category['id_category'] == 8)) continue;

Change 2 to the ID of the customer group you want to hide the categories from.

Rochy thank you very much for your help, i'll test it .

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...