class Inchoo_Dispatcher_Model_Observer
来源:互联网 发布:钉钉saas的数据架构 编辑:程序博客网 时间:2024/06/05 02:26
class
Inchoo_Dispatcher_Model_Observer
{
//this is hook to Magento's event dispatched before action is run
public
function
hookToControllerActionPreDispatch(
$observer
)
{
//we compare action name to see if that's action for which we want to add our own event
if
(
$observer
->getEvent()->getControllerAction()->getFullActionName() ==
'checkout_cart_add'
)
{
//We are dispatching our own event before action ADD is run and sending parameters we need
Mage::dispatchEvent(
"add_to_cart_before"
,
array
(
'request'
=>
$observer
->getControllerAction()->getRequest()));
}
}
public
function
hookToControllerActionPostDispatch(
$observer
)
{
//we compare action name to see if that's action for which we want to add our own event
if
(
$observer
->getEvent()->getControllerAction()->getFullActionName() ==
'checkout_cart_add'
)
{
//We are dispatching our own event before action ADD is run and sending parameters we need
Mage::dispatchEvent(
"add_to_cart_after"
,
array
(
'request'
=>
$observer
->getControllerAction()->getRequest()));
}
}
public
function
hookToAddToCartBefore(
$observer
)
{
//Hooking to our own event
$request
=
$observer
->getEvent()->getRequest()->getParams();
// do something with product
Mage::log(
"Product "
.
$request
[
'product'
].
" will be added to cart."
);
}
public
function
hookToAddToCartAfter(
$observer
)
{
//Hooking to our own event
$request
=
$observer
->getEvent()->getRequest()->getParams();
// do something with product
Mage::log(
"Product "
.
$request
[
'product'
].
" is added to cart."
);
}
}
- class Inchoo_Dispatcher_Model_Observer
- class
- class
- class
- class
- class
- class
- Class
- Class
- class
- Class
- Class<?>
- class
- Class
- Class<?>
- Class
- @class
- @class
- Jan 25, 2011, 2
- 11 01 25 很杂
- 《C和指针》学习笔记(四)
- 翻译:JavaScript and Ant
- Jquery实现Tab效果
- class Inchoo_Dispatcher_Model_Observer
- flex调试问题
- java 基本数据
- mips下的pppoe驱动
- ecshop 中category 页面分页page_size
- JS json object 与 string 相互转换
- NetBeans 时事通讯(刊号 # 134 - Jan 25, 2011)
- GetNetPath
- speeding up Magento!