【发布时间】:2013-12-06 21:53:36
【问题描述】:
当有人点击下订单但它没有触发时,我正在尝试运行一个事件。我知道它有效,因为我可以将事件更改为产品更新,并且当我更新产品时它会写入日志文件。我正在使用粉碎杂志教程,只是更改事件。
我已经尝试了这两个事件:
checkout_submit_all_aftercheckout_onepage_controller_success_action
我做错了什么?
配置.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
<?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'
);
}
}
【问题讨论】: