Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento:控制器\u操作\u预火花塞不工作_Magento - Fatal编程技术网

Magento:控制器\u操作\u预火花塞不工作

Magento:控制器\u操作\u预火花塞不工作,magento,Magento,我正在尝试创建控制器\u操作\u预触发事件: 这是我的Mbyte/Pushnotification/etc/config.xml文件代码 <events> <controller_action_predispatch_mbyte_pushnotification_index_index> <observers> <Mbyte_Pushnotificatio

我正在尝试创建控制器\u操作\u预触发事件:

这是我的Mbyte/Pushnotification/etc/config.xml文件代码

   <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>
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\u action\u predispatch\u pushnotification\u index\u index
而不是
controller\u action\u predispatch\u mbyte\u pushnotification\u index\u index

如果您没有修改控制器的前端名称(“pushnotification”)

因此,您必须将config.xml更新为

<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>

Mbyte_Pushnotification_Model_Observer
indexPreDispatch
你也可以写

<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>

通知/观察员
indexPreDispatch

如果您将模块命名为“pushnotification”,我假设。

根据magento定义,事件依赖项应该是

controller_action_predispatch_frontName_Controller_Youaction
它的定义如下:

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

它不会纠正您的错误,但会像使用公共函数indexPreDispatch(Varien\u Event\u observer$observer)一样使用$observer。我尝试了这个,但不适用于meI尝试了这个,但不适用于我。你能举例说明吗。