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.

  • What exactly you want to achieve by change/override framework file? You may have other options as well? – Muhammad Ayaz Jul 25 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 Jul 27 at 5:14
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

  • As mentioned earlier, it didn't worked. – groy Jul 26 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, privacy policy and cookie policy

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