Reputation: 134
I made an observer for category creation and it works fine in localhost (on Mac) and doesn't work fine on the server (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>
and this is 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);
}
}
and this is Vmo_CategoryToAttributeOption.xml:
<?xml version="1.0"?>
<config>
<modules>
<Vaimo_CategoryToAttributeOption>
<active>true</active>
<codePool>local</codePool>
</Vaimo_CategoryToAttributeOption>
</modules>
</config>
Do you have any idea what is wrong? Because on localhost it works great, but on the live server it doesn't.
Upvotes: 0
Views: 523
Reputation: 15216
My money is on the fact that your local machine is on Windows/MAC and the server is linux.
on Windows/MAC the file names are case insensitive and on linux they are case sensitive.
You declared the class in your event like this:
<class>vmo_categorytoattributeoption_model_observer</class>
This means Magento looks for the class in the file vmo/categorytoattributeoption/model/observer.php
. On windows/MAC it finds it, on linux it does not exist.
To solve it declare the model like this:
<class>Vmo_CategoryToAttributeOption_Model_Observer</class>
Or better yet, in the standard way
<class>vmo_categorytoattributeoption/observer</class>
Upvotes: 7