1

I can't seem to figure out how to get my observer fire.

Everywhere I look the examples on how to implement one differ ever so slightly in where capitals go and simple things like that. So here's my code, please point out what I'm doing wrong!

app/etc/modules/Mynamespace_Mymodule.xml

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

app/code/local/Mynamespace/Mymodule/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mynamespace_Mymodule>
            <version>1.0.0</version>
        </Mynamespace_Mymodule>
    </modules>
    <global>
        <models>
            <mynamespacemymodule>
                <class>Mynamespace_Mymodule_Model</class>
            </mynamespacemymodule>
        </models>
        <events>
            <checkout_type_onepage_save_order_after>
                <observers>
                    <mynamespace_mymodule>
                        <type>singleton</type>
                        <class>mynamespace_mymodule/Observer</class>
                        <method>on_order_changed</method>
                    </mynamespace_mymodule>
                </observers>
            </checkout_type_onepage_save_order_after>
        </events>
    </global>
</config>

app/code/local/Mynamespace/Mymodule/Model/Observer.php

<?php

class Mynamespace_Mymodule_Model_Observer extends Varien_Event_Observer
{  
    public function __construct() {
    }

    public function on_order_changed($observer) {
        try {
            $mail = Mage::getModel('core/email');
            $mail->setToName('Your Name');
            $mail->setToEmail('matt@richmondday.com');
            $mail->setBody('Mail Text / Mail Content');
            $mail->setSubject('Mail Subject');
            $mail->setFromEmail('matt@richmondday.com');
            $mail->setFromName("Msg to Show on Subject");
            $mail->setType('html');
            $mail->send();
        } catch (Exception $e) {
            Mage::logException($e);
        }
    }
}

?>
2

Try using

<class>entire_path_to_class_Observer</class>

instead of

<class>mynamespace_mymodule/Observer</class>

See this for some more reference.

1
  • This solved the problem. Thanks a million times!
    – hibyprime
    Oct 17 '14 at 16:12
-1

Try removing extends Varien_Event_Observer from your Observer.php. It is the class of the $observer being passed into your on_order_changed method but is not commonly used as the parent class for the observing class itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.