magentomagento2magento2.2

How remove link from customer menu when customer in general group?


How do I remove a link from customer menu when customer group is general?

I know about the ifconfig tag, but it does not give me the possibility to hide a custom link when a customer in the general group.

I use Magento 2.2.4.

Customer menu


Solution

  • class Current extends \Magento\Framework\View\Element\Html\Link\Current //block
    {
        /**
         * @return string
         */
        public function toHtml()
        {
            if (SOME CONDITION HERE) {
                return parent::toHtml(); //show link
            }
    
        return ''; //hide link
    }
    

    //Layout

    <referenceBlock name="customer_account_navigation">
            <block class="...\Current" name="customer-account-navigation-product">
                <arguments>
                    <argument name="path" xsi:type="string">.../index</argument>
                    <argument name="label" xsi:type="string">Product</argument>
                </arguments>
            </block>
        </referenceBlock>