I need constructor or init function that can be run for my custom module. I need to call it every time when request made to my module's controller in magento.


You can add following function to use your logic to your custom module's controller:

   protected function _construct()
        // your logic of construct

I hope this will help


Magento already has this. You can use _construct if you want your logic when the controller is instantiated or you can use preDispatch that is called when an action is called.
Just make sure that your controller extends Mage_Core_Controller_Front_Action if it's a frontend controller or Mage_Adminhtml_Controller_Action if it's an admin controller.

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.