2

I'm trying to write something that automatically clears cache on magento, when user hits Save, on any pages under Backend / Stores / Configuration.

I'm only looking for the proper event to hook into for this function.

Thanks.

Edit: Or any tips on adding a Save And Clear button.

4

vendor/magento/module-config/Model/Config.php

Check save method. Following event dispatch:

$this->_eventManager->dispatch(
    "admin_system_config_changed_section_{$this->getSection()}",
    ['website' => $this->getWebsite(), 'store' => $this->getStore()]
);

Ex. For catalog section event should be: admin_system_config_changed_section_catalog

  • If I use that event for clearing cache, is $this->_appConfig->reinit(); (a few lines after) gonna interfere in any way ? – Mac A. Jul 17 at 16:15
  • You can use $this->_appConfig->reinit() for clearing config cache. more detail vendor/magento/framework/App/Config.php::clean – Sohel Rana Jul 17 at 16:24

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.