magento-1.9,event-observer,controllers – Magento 1.9: Call Event and Observer Only for Custom Controller

controllersevent-observermagento-1.9

I am Find A Solution to call event when my controller is run. I found solution but is working on every controller run

<global>
   <events>
    <controller_action_predispatch>
     <observers>
            <controller_action_before>
                <class>Mycustom_Custom_Model_Observer</class>
                <method>myFunction</method>
            </controller_action_before>
        </observers>
     </controller_action_predispatch>
   </events>
</global>

I need to run myFunction when my Module Controller is run

Best Answer

I found Solution. Good trick

<global>
  <events>
<controller_action_predispatch_mycustomcontrollerhandler>
 <observers>
        <controller_action_before>
            <class>Mycustom_Custom_Model_Observer</class>
            <method>myFunction</method>
        </controller_action_before>
    </observers>
 </controller_action_predispatch_mycustomcontrollerhandler>

For example I need to call event On Product listing Page I use

 <controller_action_predispatch_catalog_product_list>