HALP! This is my first attempt at this kind of thing. It seems that the function won't fire when the event happens. (Eventually, what's supposed to happen is that when the event
Mage::dispatchEvent('nextbits_form_save_after',array('form_data'=>$params, 'form_model'=>$formModel));
occurs, the form data will be routed to appropriate people based on the data contained in the form.....)
I haven't written that code yet, but I don't see the observer catching the event and doing anything at all. What is the problem with my event/observer structures?
Observer.php: [\app\code\local\Westcott\EmailRouter\Model\Observer.php]
<?php
class Westcott_EmailRouter_Model_Observer {
public function Notify_by_Mail($observer){
if (isset($observer['form_data'])) {
$form_data = $observer['form_data'];
//$form_model = $observer['form_model'];
foreach ($form_data as $key =>$fd) {
//Do something with the form data
echo "K: ".$key." => ".$fd."<br/>";
}
/*
foreach ($form_model as $key =>$fm) {
//Do something with the form data
echo "K: ".$key." => ".$fm."<br/>";
}
*/
} else {
//Do something else with the form data...
}
}
echo "Hello!!";
}
Westcott_EmailRouter.xml: [\app\etc\modules\Westcott_EmailRouter.xml]
<?xml version="1.0"?>
<config>
<modules>
<Westcott_EmailRouter>
<active>true</active>
<codePool>local</codePool>
</Westcott_EmailRouter>
</modules>
</config>
config.xml: [\app\code\local\Westcott\EmailRouter\etc\config.xml]
<?xml version="1.0"?>
<config>
<modules>
<Westcott_EmailRouter>
<version>0.1.0</version>
</Westcott_EmailRouter>
</modules>
<global>
<models>
<emailrouter>
<class>Westcott_EmailRouter_Model</class>
</emailrouter>
</models>
<events>
<nextbits_form_save_after>
<observers>
<Westcott_EmailRouter>
<!--<type>singleton</type>-->
<class>westcott_emailrouter/observer</class>
<method>Notify_by_Mail</method>
</Westcott_EmailRouter>
</observers>
</nextbits_form_save_after>
</events>
</global>
</config>
emailrouter, but you declare your observer class alias withwestcott_emailrouter/observer. The latter should beemailrouter/observer. – nevvermind Apr 09 '14 at 20:37