Reputation: 2286
I'm attempting to use multiple observer classes & modules for Magento, all of which are being put into app/code/local. These all work on my local workstation, but will NOT work when I copy them to production via FTP. I am going crazy trying to figure out what's going on. All of my code seems sound. Here's an example of an observer:
app/code/local/Mural/Pricing/Model/Observer.php
<?php
class Mural_Pricing_Model_Observer {
public function setMuralPricing($observer) {
echo 'We did it!';
die();
}
}
app/code/local/Mural/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Mural_Pricing>
<version>0.0.1</version>
</Mural_Pricing>
</modules>
<global>
<models>
<Mural_Pricing>
<class>Mural_Pricing_Model</class>
</Mural_Pricing>
</models>
</global>
<adminhtml>
<events>
<sales_quote_add_item>
<observers>
<Mural_Pricing>
<class>mural_pricing/observer</class>
<method>setMuralPricing</method>
</Mural_Pricing>
</observers>
</sales_quote_add_item>
</events>
</adminhtml>
</config>
app/etc/modules/Mural_Pricing.xml
<?xml version="1.0"?>
<config>
<modules>
<Mural_Pricing>
<codePool>local</codePool>
<active>true</active>
<depends>
<Mage_Catalog />
</depends>
</Mural_Pricing>
</modules>
</config>
Like I said, this works fine locally, but not in production, with several different observers & modules. Frustrating. Thank you in advance!
Upvotes: 3
Views: 406
Reputation: 24406
The first thing I notice is that your observer declaration is to call mural_pricing/observer::setMuralPricing()
on your observed event.
If you look at the config XML, you're registering models in this module as Mural_Pricing/...
as per this XML:
<models>
<Mural_Pricing>
<class>Mural_Pricing_Model</class>
</Mural_Pricing>
</models>
Magento best practice seems to be to use all lowercase for class aliases, so I suggest you change that to mural_pricing
. It will also work if you change your observer declaration to use the uppercased equivalent.
On another point, I don't think it actually matters what you name this tag, but the <Mural_Pricing>
tag underneath <observers>
should ideally represent a short description of what your observer does (again, don't think it actually matters) - e.g. <mural_pricing_set_pricing>
.
Finally, it has to be said - ensure that you've cleared your cache correctly to re-parse the XML configuration. If you're using Redis or another caching architecture in production vs dev/staging/local then you may have forgotten to clear your cache a different way to how you do it locally.
Ultimately, your module looks fine other than the case difference in the class alias and observer declaration.
Upvotes: 1