客戶對象爲空,因爲controller_action_postdispatch_customer_account_createpost
事件是控制器操作事件,並且與客戶對象無關。這一事件在下面的代碼
#File: app/code/core/Mage/Core/Controller/Varien/Action.php
public function postDispatch()
{
if ($this->getFlag('', self::FLAG_NO_POST_DISPATCH)) {
return;
}
Mage::dispatchEvent(
'controller_action_postdispatch_'.$this->getFullActionName(),
array('controller_action'=>$this)
);
Mage::dispatchEvent(
'controller_action_postdispatch_'.$this->getRequest()->getRouteName(),
array('controller_action'=>$this)
);
Mage::dispatchEvent('controller_action_postdispatch', array('controller_action'=>$this));
}
具體下達,
Mage::dispatchEvent(
'controller_action_postdispatch_'.$this->getRequest()->getRouteName(),
array('controller_action'=>$this)
);
位。 ($this->getRequest()->getRouteName()
返回customer_account_createpost
)。請注意,
array('controller_action'=>$this)
傳遞到事件調度 - 這意味着你可以從你的觀察有以下
$observer->getControllerAction();
$observer->getData('controller_action');
訪問控制器對象也可以得到可變數據的密鑰列表觀察者與
var_dump(
array_keys($observer->getData())
);
的「其他分機」(由我假設你的意思是另一部分的觀測對象)可能聽不同的事件,一個是在傳遞一個customer
反對事件。例如,考慮customer_login
事件。
#File: app/code/core/Customer/Model/Session.php
public function setCustomerAsLoggedIn($customer)
{
$this->setCustomer($customer);
Mage::dispatchEvent('customer_login', array('customer'=>$customer));
return $this;
}
這裏事件調度包括客戶對象
array('customer'=>$customer)
這意味着客戶會在你的觀察是可用的。
謝謝你澄清這一點。利用這一點,我能夠獲得我所需要的信息,而且你對所有事情都很滿意。謝謝! – 2013-05-08 12:47:49