Important

Okay
  Public Ticket #1441523
Display different megamenus based on user group
Closed

Comments

  • TG Dev started the conversation

    What we are trying to accomplish is having 2 Megamenu's, one that is visible to non-logged in users /general public, and the other visible only to dealers. In the admin, we have both set to "enabled", and both restricted by "customer groups". This in theory should accomplish what we need, but is not.

    I found this link to a support page covering how to add a menu to the frontend. Is what I am describing as simple as adding the dealer menu to the xml file show in the link above? If so, what is the edit?

  •  1,344
    Land of replied

    Hello Mate,

    Have a nice day!

    For now you can add the file "/app/code/Ves/Megamenu/view/frontend/layout/default.xml" into your custom template of your site to load more menu profiles on a block position. The code to call menu profile as this:

    <referenceBlock name="store.menu">
    <block class="Ves\Megamenu\Block\Menu" name="catalog.topnav" template="Ves_Megamenu::topmenu.phtml">
    <arguments>
    <argument name="alias" xsi:type="string">top-menu</argument>
    </arguments> 
    </block>
    </referenceBlock>

    Did your site enabled full page cache option and you get the problem can not use restrict customer group for menu profile? I checked it on my local site without problem.

  • TG Dev replied

    Hello, what is the correct code to add another menu? I tried this:

    <referenceBlock name="store.menu">
       <block class="Ves\Megamenu\Block\Menu" name="catalog.topnav" template="Ves_Megamenu::topmenu.phtml">
        <arguments>
         <argument name="alias" xsi:type="string">test-menu</argument>
         <argument name="alias" xsi:type="string">b2b-menu</argument>
        </arguments>    </block>
      </referenceBlock>

    (Notice the second argument) But this code broke the site and produced the attached errors.

    What we need is for customers to see only "test-menu" and for logged in dealers to see "b2b-menu". Does this make sense? In the admin, I have both menus created, enabled, but limited by user groups. So things are set up as would be expected in the admin.

    Thanks,


  •  1,344
    Land of replied

    Hello TG Dev,

    Have a nice day!

    The code is wrong. Please try to use the code:

    <referenceBlock name="store.menu">
       <block class="Ves\Megamenu\Block\Menu" name="catalog.topnav" template="Ves_Megamenu::topmenu.phtml">
        <arguments>
         <argument name="alias" xsi:type="string">test-menu</argument>
        </arguments>
        </block>


        <block class="Ves\Megamenu\Block\Menu" name="catalog.topnav.b2b" template="Ves_Megamenu::topmenu.phtml">
        <arguments>
          <argument name="alias" xsi:type="string">b2b-menu</argument>
        </arguments>    
        </block>
    </referenceBlock>


  • TG Dev replied

    Thank you very much!

    That worked perfectly... We appreciate your excellent service so far.

    You can close this ticket.

  •  1,344
    Land of replied

    You are welcome!

    Please submit new ticket if you need any other assistant!