Php Magento-正在侦听订单状态更改的扩展

Php Magento-正在侦听订单状态更改的扩展,php,magento,Php,Magento,我正在使用Magento 1.9.0.1 我正在尝试创建一个非常简单的扩展,用于侦听订单状态更改 以下是我迄今为止所做的工作: 文件:/VivasIndustries/SmsNotification/etc/config.xml: <?xml version="1.0"?> <config> <modules> <VivasIndustries_SmsNotification> <version>0.1.0<

我正在使用Magento 1.9.0.1

我正在尝试创建一个非常简单的扩展,用于侦听订单状态更改

以下是我迄今为止所做的工作:

文件:/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>
文件:/VivasIndustries/SmsNotification/Model/Observer.php:

<?PHP
class VivasIndustries_SmsNotification_Model_Observer
{
    public function orderSaved(Varien_Event_Observer $observer)
    {
        Mage::log("Test")
    }
}
文件:/app/etc/modules/VivasIndustries\u 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>
我已经按照本指南完成了所有工作:

问题是,当我签出system.log文件时,没有包含Test的行或文本。似乎不是在日志文件中插入此文本使我认为在我更改订单状态/保存订单时无法识别

你能告诉我哪里出了错,帮我解决这个问题吗


提前谢谢

尝试在事件节点中添加以下类型:

<events>
        <sales_order_save_after>
            <observers>
                <vivasindustries_smsnotification>
<type>model</type>
                    <class>smsnotification/observer</class>
                    <method>orderSaved</method>
                </vivasindustries_smsnotification>
            </observers>
        </sales_order_save_after>
    </events>

另外,要检查代码是否正常工作,请添加一个echo“something”;出口在观察者函数中。转到后端并取消任何订单。由于订单状态将更改为“已取消”,这也应分派您的功能

您的观察者模型和app/etc/modules/xml文件是正确的。您需要将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>
                    <smsnotification>
                        <type>model</type>
                        <class>VivasIndustries_SmsNotification_Model_Observer</class>
                        <method>orderSaved</method>
                    </smsnotification>
                </observers>
            </sales_order_save_after>
        </events>
    </global>
</config>
还建议您可以删除Model Observer.php中明确提到的对象类型

您只需通过:


公共函数orderSaved$observer

我已经做了您让我做的更改,但它似乎不再起作用了:我发现以下更改:1 config.xml中的Close标记2将配置事件更改为以下内容:model VivasiIndustries\u SmsNotification\u model\u Observer orderSaved 3请检查结尾处的所有文件权限请使用新的数据,因为我不能明白你的答案像一个评论。谢谢