订单处的Magento观察员事件未触发 [英] Magento Observer Event on Order Place not firing

查看:88
本文介绍了订单处的Magento观察员事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当有人单击下单时,我正在尝试运行一个事件,但未触发.我知道它是有效的,因为我可以将事件更改为产品更新,并且当我更新产品时,它会写入日志文件中.我正在使用粉碎杂志教程,只是更改了事件.

I'm trying to run an event when someone clicks place order however it's not firing. I know it works because I can change the event to product update and when I update a product it writes in the log file. I'm using the smashing magazine tutorial, just changing the event.

我已经尝试了以下两个事件:

I've tried both of these events:

  • checkout_submit_all_after
  • checkout_onepage_controller_success_action
  • checkout_submit_all_after
  • checkout_onepage_controller_success_action

我在做什么错了?

Config.xml

Config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <SmashingMagazine_LogProductUpdate>
            <version>0.0.1</version>
        </SmashingMagazine_LogProductUpdate>
    </modules>

    <!-- Configure our module's behavior in the global scope -->
    <global>

        <!-- Defining models -->
        <models>

            <!--
                Unique identifier in the model's node.
                By convention, we put the module's name in lowercase.
            -->
            <smashingmagazine_logproductupdate>

                <!--
                    The path to our models directory, with directory
                    separators replaced by underscores
                -->
                <class>SmashingMagazine_LogProductUpdate_Model</class>

            </smashingmagazine_logproductupdate>

        </models>

        <events>
            <checkout_submit_all_after>
                <observers>
                    <smashingmagazine_logproductupdate>
                        <class>smashingmagazine_logproductupdate/observer</class>
                        <method>logUpdate</method>
                        <type>singleton</type>
                    </smashingmagazine_logproductupdate >
                </observers>
            </catalog_product_save_after>
        </events>

    </global>

</config>

Observer.php

Observer.php

<?php
/**
 * Our class name should follow the directory structure of
 * our Observer.php model, starting from the namespace,
 * replacing directory separators with underscores.
 * i.e. app/code/local/SmashingMagazine/
 *                     LogProductUpdate/Model/Observer.php
 */

class SmashingMagazine_LogProductUpdate_Model_Observer
{
    /**
     * Magento passes a Varien_Event_Observer object as
     * the first parameter of dispatched events.
     */
    public function logUpdate(Varien_Event_Observer $observer)
    {



        // Write a new line to var/log/product-updates.log
        $name = 'asdf';
        $sku = 'weee';
        Mage::log(
            "{$name} ({$sku}) updated",
            null, 
            'product-updates.log'
        );
    }
}

推荐答案

只需尝试以下示例即可直接放置观察者类和语法,并且在</smashingmagazine_logproductupdate >之类的唯一标记中有空格,应该为</smashingmagazine_logproductupdate>

just try with below example to put observer class directly and syntax as well as you have space in unique tag like </smashingmagazine_logproductupdate > this should be </smashingmagazine_logproductupdate>

<events> 
     <checkout_submit_all_after>
          <observers>
            <smashingmagazine_logproductupdate>
                 <class>SmashingMagazine_LogProductUpdate_Model_Observer</class>
                 <method>logUpdate</method>
            </smashingmagazine_logproductupdate>
          </observers>
     </checkout_submit_all_after>
</events>      

希望这一定会帮助您解决问题.

hope this will sure help you to solve your issue.

这篇关于订单处的Magento观察员事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆