Magento observer在本地主机上工作,而不是在服务器上


Magento observer works on localhost and not on the server

我为类别创建做了一个观察者,它在localhost(在Mac上)上运行良好,在服务器(Linux)上运行不好。

config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Vmo_CategoryToAttributeOption>
            <version>0.1.0</version>
        </Vmo_CategoryToAttributeOption>
    </modules>
    <global>
        <models>
            <vmo_categorytoattributeoption>
                <class>Vmo_CategoryToAttributeOption_Model</class>
            </vmo_categorytoattributeoption>
        </models>
        <helpers>
            <vmo_categorytoattributeoption>
                <class>Vmo_CategoryToAttributeOption_Helper</class>
            </vmo_categorytoattributeoption>
        </helpers>
        <events>
            <catalog_category_prepare_save>
                <observers>
                    <vmo_categorytoattributeoption_model_observer>
                        <class>vmo_categorytoattributeoption_model_observer</class>
                        <method>savecategoryobserver</method>
                    </vmo_categorytoattributeoption_model_observer>
                </observers>
            </catalog_category_prepare_save>
        </events>
    </global>
</config>

这是local/Vmo/CategoryToAttributeOption/Model/Observer.php

class Vmo_CategoryToAttributeOption_Model_Observer extends Varien_Event_Observer
{
    public function __construct()
    {
    }
    public function savecategoryobserver($observer)
    {
        $event = $observer->getEvent();
        $cat_model = $event -> getCategory();
        $name = $cat_model->getName();
        Mage::log("works: " . $name);
    }
}

这是Vmo_CategoryToAttributeOption.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Vaimo_CategoryToAttributeOption>
            <active>true</active>
            <codePool>local</codePool>
        </Vaimo_CategoryToAttributeOption>
    </modules>
</config>

你知道怎么了吗?因为在本地主机上它工作得很好,但在实时服务器上则不然。

我的钱花在你的本地机器在Windows/MAC上,服务器是linux上
在Windows/MAC上,文件名不区分大小写,而在linux上,它们区分大小写
您在活动中这样声明类:

<class>vmo_categorytoattributeoption_model_observer</class>

这意味着Magento在文件vmo/categorytoattributeoption/model/observer.php中查找类。在windows/MAC上它找到了它,在linux上它不存在
要解决它,请这样声明模型:

<class>Vmo_CategoryToAttributeOption_Model_Observer</class>

或者更好的是,以标准方式

<class>vmo_categorytoattributeoption/observer</class>