0

I want override command cache:flush. while execute this php bin/magento cache:flush i want to execute my custom module code. can i do? please guide me on this.

Note: i'm try to use in magento 2.4.5-p1

1 Answer 1

1

For your requirement, there are 2 ways.

  1. If you want to create event observer, then create like this :

    <event name="adminhtml_cache_refresh_type">
         <observer name="youobservername" instance="Vendor\Extension\Observer\YourcustomerObserverFile"/>
     </event>
    
  2. If you want plugin, then cache:flush command execute code from this methods.

\Magento\Backend\Controller\Adminhtml\Cache\FlushAll::execute() method.

so try to create that class plugin.

4
  • Thank you so much for guide and help can you please guide me even and plugin for when i try to use this command. module:disable module:enable module:status module:uninstall
    – Vivek
    Commented Feb 15, 2023 at 6:23
  • If above answer help you, accept and upvote, so that is help other in community. If you have seprate question ask seprately, we can help you there as well. Commented Feb 15, 2023 at 6:52
  • Ok thank you :)
    – Vivek
    Commented Feb 15, 2023 at 7:00
  • Please guide here. magento.stackexchange.com/questions/364555/…
    – Vivek
    Commented Feb 15, 2023 at 7:01

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.