magento unable to load the observe class

和自甴很熟 提交于 2019-12-04 22:39:51
open-ecommerce.org

This is what I am using to run the observer when a new product is added to the cart:

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>

Helper\Data.php

    <?php
    class Iln_Cartvalidation_Helper_Data extends Mage_Core_Helper_Abstract {
    } 

Model\observer.php

<?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);
    }

}

Judging by the include warning, it seems like you have the compiler enabled but it cannot find the (flattened) file.

So either disable the compiler:

php shell/compiler.php disable

Or run a compilation so that it will generate the file for you:

php shell/compiler.php compile

I think it should helps to you:

<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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!