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 magento无法加载observe类_Events_Magento_Observers - Fatal编程技术网

Events magento无法加载observe类

Events magento无法加载observe类,events,magento,observers,Events,Magento,Observers,当我试图为签出\u键入\u onepage\u保存\u顺序事件编写观察者时,如下所示 <events> <checkout_type_onepage_save_order> <observers> <Appeal_Consignor_Model_Observer> <type>singleton</type> &l

当我试图为
签出\u键入\u onepage\u保存\u顺序
事件编写观察者时,如下所示

<events>
    <checkout_type_onepage_save_order>
        <observers>
            <Appeal_Consignor_Model_Observer>
                <type>singleton</type>
                <class>consignor/observer</class>
                <method>savedata</method>
            </Appeal_Consignor_Model_Observer>
        </observers>
    </checkout_type_onepage_save_order>
</events>
完整的config.xml文件如下所示

<?xml version="1.0"?>
<config>
    <modules>
        <Appeal_Consignor>
            <version>1.0.1</version>
        </Appeal_Consignor>
    </modules>

    <global>
        <models>
            <consignor>
                <class>Appeal_Consignor_Model</class>
            </consignor>
        </models>
        <resources>
            <consignor_setup>
                <setup>
                    <module>Appeal_Consignor</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </consignor_setup>
            <consignor_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </consignor_write>
            <consignor_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </consignor_read>
        </resources>
        <helpers>
            <consignor>
                <class>Appeal_Consignor_Helper</class>
            </consignor>
        </helpers>
    </global>


    <frontend>
        <routers>
            <consignor>
                <use>standard</use>
                <args>
                    <module>Appeal_Consignor</module>
                    <frontName>consignor</frontName>
                </args>
            </consignor>
        </routers>


        <events>
            <checkout_type_onepage_save_order>
                <observers>
                    <Appeal_Consignor_Model_Observer>
                        <type>singleton</type>
                        <class>Appeal_Consignor_Model_Observer</class>
                        <method>savedata</method>
                    </Appeal_Consignor_Model_Observer>
                </observers>
            </checkout_type_onepage_save_order>

        </events>


    </frontend>
    <adminhtml>
        <layout>
            <updates>
                <consignor>
                    <file>consignor.xml</file>
                </consignor>
            </updates>
        </layout>


    </adminhtml>

</config>

]:无法打开流:第93行的E:\xampp\htdocs\magento\includes\src\Varien\u Autoload.php中没有此类文件或目录
2012-07-23T11:04:09+00:00错误(3):警告:include()[]:在第93行的E:\xampp\htdocs\magento\includes\src\Varien\u Autoload.php中打开“上诉委托人\模型\观察者.php”以供包含失败(include\path='E:\xampp\htdocs\magento\includes\src\Varien\u Autoload.php')

根据include警告判断,似乎启用了编译器,但它找不到(展平的)文件

因此,请禁用编译器:

php shell/compiler.php disable
或运行编译,以便为您生成文件:

php shell/compiler.php compile

我认为这应该对你有所帮助:

<events>
    <checkout_type_onepage_save_order>
        <observers>
            <consignor>
                <type>model</type>
                <class>consignor/observer</class>
                <method>savedata</method>
            </consignor>
        </observers>
    </checkout_type_onepage_save_order>
</events>

模型
发货人/观察员
保存数据

这是我在将新产品添加到购物车时用来运行observer的方法:

etc\config.xml

  <?xml version="1.0"?>
    <config>
        <modules>
            <Iln_Cartvalidation>
                <version>0.1.0</version>
            </Iln_Cartvalidation>
        </modules>
        <global>
            <helpers>
                <cartvalidation>
                    <class>Iln_Cartvalidation_Helper</class>
                </cartvalidation>
            </helpers>
        </global>
        <frontend>
            <events>
                <checkout_cart_product_add_after>
                    <observers>
                        <Iln_Cartvalidation_Model_Observer>
                            <type>singleton</type>
                            <class>Iln_Cartvalidation_Model_Observer</class>
                            <method>Mytestmethod</method>
                        </Iln_Cartvalidation_Model_Observer>
                    </observers>
                </checkout_cart_product_add_after>
            </events>
        </frontend>
    </config>

0.1.0
Iln\u Cartvalidation\u助手
独生子女
Iln\u Cartvalidation\u模型\u观察者
Mytestmethod
Helper\Data.php

    <?php
    class Iln_Cartvalidation_Helper_Data extends Mage_Core_Helper_Abstract {
    } 

对于magento<2.0,您应该以这种方式编写
委托人/观察者
。您还可以删除
节点。然后在
.htaccess
文件集env var
SetEnv MAGE_是开发者模式1
。在那之后,请提供我们即将到来的结果,请也张贴您的模型文件。我相信您一定检查过很多次,可能是config.xmlThis中的类名与不匹配。查看include中的文件名。包括(上诉委托人模型观察者php)。每当你看到一个完全带下划线的文件名时,这意味着Magento正在编译文件夹中查找一个文件。这正是@AlanStorm所说的。另一个给出它的东西是include路径(includes\src)。
  <?xml version="1.0"?>
    <config>
        <modules>
            <Iln_Cartvalidation>
                <version>0.1.0</version>
            </Iln_Cartvalidation>
        </modules>
        <global>
            <helpers>
                <cartvalidation>
                    <class>Iln_Cartvalidation_Helper</class>
                </cartvalidation>
            </helpers>
        </global>
        <frontend>
            <events>
                <checkout_cart_product_add_after>
                    <observers>
                        <Iln_Cartvalidation_Model_Observer>
                            <type>singleton</type>
                            <class>Iln_Cartvalidation_Model_Observer</class>
                            <method>Mytestmethod</method>
                        </Iln_Cartvalidation_Model_Observer>
                    </observers>
                </checkout_cart_product_add_after>
            </events>
        </frontend>
    </config>
    <?php
    class Iln_Cartvalidation_Helper_Data extends Mage_Core_Helper_Abstract {
    } 
<?php
class Iln_Cartvalidation_Model_Observer {

    public function Mytestmethod($observer) {
        $event = $observer->getEvent(); //Fetches the current event
        $product = $event->getProduct();
        $eventmsg = "Current Event Triggered : " . $event->getName() . "Currently Added Product : " . $product->getName();
        //Adds Custom message to shopping cart
        echo Mage::getSingleton('checkout/session')->addSuccess($eventmsg);
        //Your Custom Logic Here
        print_r($product);
    }

}