2014-10-03 3 views
0

작동하지 않습니다 : 내 메가 바이트/Pushnotification을/etc/config.xml 파일의 코드젠토 : controller_action_predispatch 내가 controller_action_predispatch 이벤트 만들려고하고

<events> 
      <controller_action_predispatch_mbyte_pushnotification_index_index> 
       <observers> 
        <Mbyte_Pushnotification> 

         <class>Mbyte_Pushnotification/Observer</class> 
         <method>indexPreDispatch</method> 
        </Mbyte_Pushnotification> 
       </observers> 
      </controller_action_predispatch_mbyte_pushnotification_index_index> 
    </events> 

내 컨트롤러 코드 : 메가 바이트/Pushnotification/컨트롤러/IndexController.php 파일 코드

class Mbyte_Pushnotification_IndexController extends Mage_Core_Controller_Front_Action 
{ 

    public function indexAction() 
    { 
    Mage::log('Run',null,'log.log'); 

    } 
    } 

관찰자 파일 코드 :

,
class Mbyte_Pushnotification_Model_Observer { 
       public function indexPreDispatch($observer) 
       {  
       Mage::log('Check',null,'observer.log'); 

         }} 

controller_action_predispatch가 작동하지 않습니다. 내가 잘못하고있는 것이 있습니까?

+0

하지만, 공공 기능 indexPreDispatch'처럼 $ 관찰자 캐스트 (Varien_Event_Observer의 $ 옵저버) ' – apouey

+0

나는 이것을 시도했지만 나를 위해 작동하지 않았다 –

답변

0

이벤트는

controller_action_predispatch_pushnotification_index_index 대신 당신이 당신의 컨트롤러의 프론트 엔드 이름 ("pushnotification")을 수정하지 않은 경우 controller_action_predispatch_mbyte_pushnotification_index_index

이어야한다 트리거.

따라서 당신은 내가 생각 모듈 "pushnotification을"라는 이름의 경우도

<events> 
     <controller_action_predispatch_pushnotification_index_index> 
      <observers> 
       <Mbyte_Pushnotification> 
        <class>pushnotification/observer</class> 
        <method>indexPreDispatch</method> 
       </Mbyte_Pushnotification> 
      </observers> 
     </controller_action_predispatch_pushnotification_index_index> 
</events> 

를 작성할 수

<events> 
     <controller_action_predispatch_pushnotification_index_index> 
      <observers> 
       <Mbyte_Pushnotification> 
        <class>Mbyte_Pushnotification_Model_Observer</class> 
        <method>indexPreDispatch</method> 
       </Mbyte_Pushnotification> 
      </observers> 
     </controller_action_predispatch_pushnotification_index_index> 
</events> 

에 config.xml 파일을 업데이트해야합니다. 마 젠토 이벤트를 정의에 따르면

0

같이

controller_action_predispatch_frontName_Controller_Youaction 

가 정의되어 있어야한다 따라 달라집니다 : 그것은 당신의 버그를 해결하는 것은

Mage::dispatchEvent('controller_action_predispatch_' . $this->getFullActionName(), 
     array('controller_action' => $this)); 
+0

나는 이것을 시도했지만 이것은 나를 위해 작동하지 않았다. 예를 들어 설명해 주시겠습니까? –

관련 문제