0

Any one know how to override vendor/magento/framework/View/Element/Html/Link/Current.php file in M-2.3 ?

Tried:

1) Add class using XML:  failed
2) Created plugin to override the function: failed.
3) Created module and override using preference: failed
4) Created patch and override the file: failed.

Here we are overriding protected method(_toHtml()) which is not possible by plugin.

Any help would be appreciated.

2
  • What exactly you want to achieve by change/override framework file? You may have other options as well? Commented Jul 25, 2019 at 15:40
  • I want to add class for each customer account left navigations so that I can add icon for each navigation menu.
    – groy
    Commented Jul 27, 2019 at 5:14

2 Answers 2

1

add this to di.xml of your module

 <preference for="Magento\Framework\View\Element\Html\Link\Current" type="[Vendor]\[Module]\View\Element\Html\Link\Current" />

Then create the class [Vendor][Module]\View\Element\Html\Link\Current that extends Magento\Framework\View\Element\Html\Link\Current and make your changes in there

1
  • As mentioned earlier, it didn't worked.
    – groy
    Commented Jul 26, 2019 at 9:19
0

As above all above I have tried was not working so added class by js like: iterated the all li element then get the text and set it to class and used same class to add css changes.

If anyone find better answer please update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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