我为类别创建做了一个观察者,它在 localhost(在 Mac 上)中运行良好,在服务器(Linux)上运行不正常。
配置.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>
你知道有什么问题吗?因为在本地主机上它工作得很好,但在实时服务器上却不行。