“法师注册表密钥已经存在”发射事件时 [英] "Mage registry key already exists" when firing events

查看:149
本文介绍了“法师注册表密钥已经存在”发射事件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正试图勾选sales_order_save_after事件,但事件触发时我会不断收到以下错误:

  Mage注册表项_singleton / modulename / Orderobserver已经存在

Orderobserver类被正确命名,并与xml中的类的调用相匹配,但是错误仍然存​​在。调用事件的xml看起来如下:

 < events> 
< sales_order_save_after>
< observers>
< modulename>
< type> singleton< / type>
< class>模块名/ Orderobserver< / class>
< method> generateOrderFile< / method>
< / modulename>
< /观察者>
< / sales_order_save_after>
< / events>

该类名为 Companyname_Modulename_Model_Modulename_Orderobserver p>

类文件的名称和位置如下: app / code / local / Companyname / Modulename / Model / Modulename / Orderobserver.php



有趣的是,当发生错误时,服务器日志中也会记录以下错误:

 客户端被服务器配置拒绝:
/var/www/vhosts/path/to/subdomain/httpdocs/app/etc/local.xml

这可能是权限问题吗?



更新:



我查看了Magento系统日志,并且还记录了以下错误:

 无法打开Mage / Retailpro / Model / Orderobserver.php以供包含(include_path ='/ var / www / path / to / subdomain / httpdocs / app / code / local:/ var / www / path / to / subdomain /的httpdocs /应用程序/代码/社区:在/ var / WWW /路径/到/子/的httpdocs /应用程序/代码/核心:在/ var / WWW /路径/ to / subdomain / httpdocs / lib:。:')在/var/www/path/to/subdomain/httpdocs/lib/Varien/Autoload.php第93行


解决方案

首先,虽然可能不是neccesay,但是更改这个

 <类> MODULENAME / Orderobserver< /类> 

 <类> MODULENAME / orderobserver< /类> 

类别的约定都是小写。



其次,类别 modulename / orderobserver 转换为类名

  Packagename_Modulename_Model_Orderobserver 

所以你命名你的类文件错了。最后,由于Magento的自动装载机基于类名,这意味着您的文件需要位于

  app / code / local / Packagename / Modulename / Model / Orderobserver.php 


I'm Currently trying to hook into the "sales_order_save_after" event, but I constantly get the following error when the event is fired:

Mage registry key "_singleton/Modulename/Orderobserver" already exists

Now I've checked that the Orderobserver class is named correctly, and matches up with the call to the class in the xml, but the error is still occuring. The xml calling the event looks as so:

<events>
    <sales_order_save_after>
        <observers>
            <modulename>
                <type>singleton</type>
                <class>Modulename/Orderobserver</class>
                <method>generateOrderFile</method>
            </modulename>
        </observers>
    </sales_order_save_after>
  </events>

the class is named Companyname_Modulename_Model_Modulename_Orderobserver.

The class file is named and located as so: app/code/local/Companyname/Modulename/Model/Modulename/Orderobserver.php

Interestingly, the following error is also logged in the server logs when the error occurs:

client denied by server configuration: 
/var/www/vhosts/path/to/subdomain/httpdocs/app/etc/local.xml 

Could this be a permissions issue?

Update:

I've looked in the Magento system Log, and the following error is also being logged:

Failed opening 'Mage/Retailpro/Model/Orderobserver.php' for inclusion (include_path='/var/www/path/to/subdomain/httpdocs/app/code/local:/var/www/path/to/subdomain/httpdocs/app/code/community:/var/www/path/to/subdomain/httpdocs/app/code/core:/var/www/path/to/subdomain/httpdocs/lib:.:')  in /var/www/path/to/subdomain/httpdocs/lib/Varien/Autoload.php on line 93

解决方案

First, although it's probably not neccesay, change this

<class>Modulename/Orderobserver</class>

to

<class>modulename/orderobserver</class>

Convention on class aliases is they're all lowercase.

Second, the class alias modulename/orderobserver translates to a class name of

Packagename_Modulename_Model_Orderobserver

So you've named your class file wrong. Finally, since Magento's autoloader is based on class name, that means your file needs to be located at

app/code/local/Packagename/Modulename/Model/Orderobserver.php

这篇关于“法师注册表密钥已经存在”发射事件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆