<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Amasty\Reports\Block\Adminhtml\Navigation" type="Shop\Reports\Block\Adminhtml\Navigation" />

Block class:


namespace Shop\Reports\Block\Adminhtml;

class Navigation extends \Amasty\Reports\Block\Adminhtml\Navigation
    public function getConfig()

I'm trying to rewrite \Amasty\Reports\Block\Adminhtml\Navigation::getConfig method. However the original method is called when the page is loaded. When I try to rewrite other methods, they are rewritten successfully. What can be the cause of this? Thanks a lot!

1 Answer 1


Simple things to check first (you probably will have done all of these!)

  • Make sure your module is enabled and you've run setup:upgrade after enabling
  • clear the magento cache (bin/magento cache:flush)
  • recompile di if in production mode (bin/magento setup:di:compile)

If those don't resolve the issue, then my next question would be:

What is the access level of the function you are trying to overwrite? (public / protected / private)?

If it is public, it should work, but you could consider using a plugin instead: https://devdocs.magento.com/guides/v2.2/extension-dev-guide/plugins.html

It's less intrusive than overriding a whole class, and using the "around" plugin type, you can override the function.

If however, the access level is protected / private, then you'll need to override a function that calls the getConfig function as well, because php classes will use the parent class context when calling a private function (see https://stackoverflow.com/questions/3756609/strange-behavior-when-overriding-private-methods for a better explanation)

Hope this helps! :)

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.