0

I'm using Magento 1.9.0.1.

I'm trying to create a very simple extension that is listening for a order status change.

Here is what i have done so far:

File: /VivasIndustries/SmsNotification/etc/config.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <VivasIndustries_SmsNotification>
      <version>0.1.0</version>
    </VivasIndustries_SmsNotification>
  </modules>
  <global>
    <events>
        <sales_order_save_after>
            <observers>
                <vivasindustries_smsnotification>
                    <class>smsnotification/observer</class>
                    <method>orderSaved</method>
                </vivasindustries_smsnotification>
            </observers>
        </sales_order_save_after>
    </events>
  </global>

File: /VivasIndustries/SmsNotification/Model/Observer.php:

<?PHP
class VivasIndustries_SmsNotification_Model_Observer
{
    public function orderSaved(Varien_Event_Observer $observer)
    {
        Mage::log("Test")
    }
}

File: /app/etc/modules/VivasIndustries_SmsNotification.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <VivasIndustries_SmsNotification>
      <active>true</active>
      <codePool>community</codePool>
      <version>0.1.0</version>
    </VivasIndustries_SmsNotification>
  </modules>
</config>

I've done everything by this guide: http://www.danielhanly.com/blog/observing-order-status-changes-magento/

The problem is that when i check out my system.log file there is no line or text with "Test". It seems it is not inserting this text in the log file that makes me think it is not recognizing when i change order status/save order.

Can you please point me where is my mistake and help me out resolve this problem.

Thanks in advance!

1

In your <global> you forgot to define the smsnotification model.

 <models>
    <smsnotification><class>VivasIndustries_SmsNotification_Model</class></smsnotification>
 </models>

Now Magento will be able to recognize smsnotification/observer

1
  • This is definitely the solution. Make sure you also close out your tags. I notice a missing </config> tag and you're missing a semi-colon after your Mage::log(); Jan 27 '15 at 15:50
0

Magento need to know where to find your observer so you can either

1) Define you model using

....
<global>
    <models>
        <customengravedproduct>
            <class>VivasIndustries_SmsNotification_Model</class>
        </customengravedproduct>
    </models>
</global>
...

or

2) Define the location of your observer class

<events>
    <sales_order_save_after>
        <observers>
            <vivasindustries_smsnotification>
                 <type>singleton</type>
                 <class>VivasIndustries_SmsNotification_Model_Observer</class>
                 <method>orderSaved</method>
            </vivasindustries_smsnotification>
        </observers>
    </sales_order_save_after>
</events>
3
  • I've done what you told me to do in point 2 but it seems it is not working again... Jan 27 '15 at 14:25
  • Turn off all your caches, instead of using Mage::log, add exit('test'); instead (only if it's not on production). Jan 27 '15 at 14:43
  • Is your module active? Jan 27 '15 at 14:43

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.