Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.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
Events &引用;Mage注册表项已存在";触发事件时_Events_Magento_Registry - Fatal编程技术网

Events &引用;Mage注册表项已存在";触发事件时

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

我目前正在尝试挂接“sales\u order\u save\u after”事件,但在触发该事件时,我经常会遇到以下错误:

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
新项目
微波管
核心单元设置
核心写入
核心读取
独生子女
新增项目/观察员
目录\产品\保存

如果内,您将收到此错误


将其移动到要修复的标记之外的

被服务器配置拒绝的客户端是无关的。Magento有一个内部检查,试图通过HTTP请求local.xml,如果可以访问,出于安全原因,它将退出。感谢您的帮助。我做了你建议的所有更改,但仍然有相同的结果。查看magento system.log中的错误报告,它指出
无法打开“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>