Events &引用;Mage注册表项已存在";触发事件时
我目前正在尝试挂接“sales\u order\u save\u after”事件,但在触发该事件时,我经常会遇到以下错误:Events &引用;Mage注册表项已存在";触发事件时,events,magento,registry,Events,Magento,Registry,我目前正在尝试挂接“sales\u order\u save\u after”事件,但在触发该事件时,我经常会遇到以下错误: Mage registry key "_singleton/Modulename/Orderobserver" already exists 现在我已经检查了Orderobserver类的命名是否正确,并与xml中对该类的调用相匹配,但错误仍然存在。调用事件的xml如下所示: <events> <sales_order_save_after&g
Mage registry key "_singleton/Modulename/Orderobserver" already exists
现在我已经检查了Orderobserver类的命名是否正确,并与xml中对该类的调用相匹配,但错误仍然存在。调用事件的xml如下所示:
<events>
<sales_order_save_after>
<observers>
<modulename>
<type>singleton</type>
<class>Modulename/Orderobserver</class>
<method>generateOrderFile</method>
</modulename>
</observers>
</sales_order_save_after>
</events>
这可能是权限问题吗
更新:
我查看了Magento系统日志,并记录了以下错误:
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
首先,尽管可能没有必要这样做,但要改变这一点
<class>Modulename/Orderobserver</class>
所以你把你的类文件命名错了。最后,由于Magento的自动加载程序基于类名,这意味着您的文件需要位于
app/code/local/Packagename/Modulename/Model/Orderobserver.php
Microtron_Newitems_模型
newitems_mysql4
Microtron_Newitems_Model_Mysql4
新项目
微波管
核心单元设置
核心写入
核心读取
独生子女
新增项目/观察员
目录\产品\保存
如果将其移动到要修复的
无法打开“Mage/Modulename/Model/Orderobserver.php”
。这是否意味着它正在查看Mage文件夹而不是Companyname文件夹。这可能是问题的根源吗?没错。如果您的自定义模块的config.xml设置用于模型?啊,好问题。我目前正在从这家公司之前的开发人员编写的一个模块中复制,我只从我认为相关的xml中复制了一些内容。我刚刚添加了一点xml,现在可以正常工作了。谢谢你们的帮助,你们是个救生员。你们应该描述一下这一部分
<class>modulename/orderobserver</class>
Packagename_Modulename_Model_Orderobserver
app/code/local/Packagename/Modulename/Model/Orderobserver.php
<global>
<models>
<newitems>
<class>Microtron_Newitems_Model</class>
<resourceModel>newitems_mysql4</resourceModel>
</newitems>
<newitems_mysql4>
<class>Microtron_Newitems_Model_Mysql4</class>
<entities>
<newitems>
<table>newitems</table>
</newitems>
</entities>
</newitems_mysql4>
</models>
<resources>
<newitems_setup>
<setup>
<module>Microtron_Newitems</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</newitems_setup>
<newitems_write>
<connection>
<use>core_write</use>
</connection>
</newitems_write>
<newitems_read>
<connection>
<use>core_read</use>
</connection>
</newitems_read>
</resources>
<events>
<catalog_product_save_after>
<observers>
<newitems>
<type>singleton</type>
<class>newitems/observer</class>
<method>catalog_product_save</method>
</newitems>
</observers>
</catalog_product_save_after>
</events>
</global>