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
Magento mage注册表项“_单身人士/";已经存在_Magento - Fatal编程技术网

Magento mage注册表项“_单身人士/";已经存在

Magento mage注册表项“_单身人士/";已经存在,magento,Magento,我知道有很多帖子都有这个问题,但我猜每个帖子都有不同的根源(至少从我检查的情况来看,没有任何帮助) 我试图在用户单击按钮时触发事件,但我在浏览器警报Mage注册表项“\u singleton/”中得到上面提到的异常已存在 config.xml的一部分: ..... <models> <packagecustomernumber> <class>Package_CustomerNumber_Model</c

我知道有很多帖子都有这个问题,但我猜每个帖子都有不同的根源(至少从我检查的情况来看,没有任何帮助)

我试图在用户单击按钮时触发事件,但我在浏览器警报
Mage注册表项“\u singleton/”中得到上面提到的异常已存在

config.xml的一部分:

.....
     <models>
        <packagecustomernumber>
            <class>Package_CustomerNumber_Model</class>
        </packagecustomernumber>
    </models>

</global>
<frontend>
        <events>
            <checkout_type_onepage_save_order>
                <observers>
                    <type>singleton</type>
                    <class>packageName/customernumber/observer</class>
                    <method>setCustomerNumber</method>
                </observers>
            </checkout_type_onepage_save_order>
        </events>
    </frontend>
按钮,该按钮应触发“均匀it签出/保存订单”,因此事件应是正确的


有什么建议吗?

首先弹出的是这个

<class>packageName/customernumber/observer</class>

如果您不能实例化该类,那么Magento也将无法实例化(在运行某些步骤触发您的观察者之前,首先测试该类更容易)

首先弹出的是这个

<class>packageName/customernumber/observer</class>
如果您不能实例化该类,那么Magento也将无法实例化(在运行某些步骤触发您的观察者之前,首先测试该类更容易)

是的,“packageName/customernumber/observer”是问题的根源

虽然该类引用的结构完全不正确,但当您的类引用与您的全局/models/modulename定义不匹配时,实际上会出现问题。即使引用“看起来”正确

配置:

<config>
<global>
    <models>
        <mymodule>
            <class>My_Module_Model</class>
        </mymodule>
    </models>
    <events>
        <some_event_tag>
            <observers>
                <my_event_observer_method>
                    <class>my_module/observer</class>
                    <method>myEventObserverMethod</method>
                </my_event_observer_method>
            </observers>
        </some_event_tag>
    </events>
</global>
</config>

我的模块模型
my_模块/观察者
Myeventobserver方法
将产生相同的结果,因为未找到“我的模块/观察者”,因为未配置“我的模块”类组节点。此示例的正确用法应该是“mymodule/observer”

因此,如果遇到此错误,请重新读取config.xml

是的,“packageName/customernumber/observer”是问题的根源

虽然该类引用的结构完全不正确,但当您的类引用与您的全局/models/modulename定义不匹配时,实际上会出现问题。即使引用“看起来”正确

配置:

<config>
<global>
    <models>
        <mymodule>
            <class>My_Module_Model</class>
        </mymodule>
    </models>
    <events>
        <some_event_tag>
            <observers>
                <my_event_observer_method>
                    <class>my_module/observer</class>
                    <method>myEventObserverMethod</method>
                </my_event_observer_method>
            </observers>
        </some_event_tag>
    </events>
</global>
</config>

我的模块模型
my_模块/观察者
Myeventobserver方法
将产生相同的结果,因为未找到“我的模块/观察者”,因为未配置“我的模块”类组节点。此示例的正确用法应该是“mymodule/observer”


因此,如果遇到此错误,请重新读取config.xml

确保config.xml models部分包含

        <!-- This says that string 'company_module' corresponds to Company_Module_Model pseudo-namespace in getModel() and getSingleton() calls. -->
        <company_module>
            <class>Company_Module_Model</class>
        </company_module>

公司模块模型

否则,您将无法创建新的模型实例。

请确保config.xml models部分包含

        <!-- This says that string 'company_module' corresponds to Company_Module_Model pseudo-namespace in getModel() and getSingleton() calls. -->
        <company_module>
            <class>Company_Module_Model</class>
        </company_module>

公司模块模型

否则,您将无法创建新的模型实例。

是的,实例化模型类工作正常。类的路径被打印两次,正如您给我的代码中所预期的那样。现在仍然是Singleton的问题。@Syspect剩下的就是更改
packageName/customernumber/observer
节点,使其具有正确的类名或类别名,这有助于。。。显然我选择了错误的别名,但实际的类名起作用了!此外,我不得不再次禁用编译,以使错误消失。。。我早些时候关闭了编译,但不知何故它被重新启用了。是的,实例化模型类工作得很好。类的路径被打印两次,正如您给我的代码中所预期的那样。现在仍然是Singleton的问题。@Syspect剩下的就是更改
packageName/customernumber/observer
节点,使其具有正确的类名或类别名,这有助于。。。显然我选择了错误的别名,但实际的类名起作用了!此外,我不得不再次禁用编译,以使错误消失。。。我早些时候关闭了编译,但不知何故它重新启用了。您找到解决方案了吗?你能发点东西吗?@matheusjarimb-我已经不记得了,对不起。你找到解决办法了吗?你能帮我发点东西吗?@matheusjarimb-我已经不记得了,对不起。谢谢,真的节省了我的时间!谢谢,真的节省了我的时间!
        <!-- This says that string 'company_module' corresponds to Company_Module_Model pseudo-namespace in getModel() and getSingleton() calls. -->
        <company_module>
            <class>Company_Module_Model</class>
        </company_module>