共计 1782 个字符,预计需要花费 5 分钟才能阅读完成。
这其实是Magento1.4.1的一个Bug,新的而版本已经没有了,所以推荐大家升级到最新版。当然,如果你是在不喜爱那个升级,也可以按照下面的方法修改。
1. In Mage/Review/controllers/ProductController.php, change the preDispatch() method
Original Code :
[php]
<em>public function preDispatch()
{
parent::preDispatch(); </em>
$allowGuest = Mage::helper(’review’)->getIsGuestAllowToWrite();
if (!$this->getRequest()->isDispatched()) {
return;
}
$action = $this->getRequest()->getActionName();
if (!$allowGuest && $action == ‘post’ && $this->getRequest()->isPost()) {
if (!Mage::getSingleton(’customer/session’)->isLoggedIn()) {
$this->setFlag(’’, self::FLAG_NO_DISPATCH, true);
Mage::getSingleton(’customer/session’)->setBeforeAuthUrl(Mage::getUrl(’*/*/*’, array(’_current’ => true)));
Mage::getSingleton(’review/session’)->setFormData($this->getRequest()->getPost())
->setRedirectUrl($this->_getRefererUrl());
$this->_redirectUrl(Mage::helper(’customer’)->getLoginUrl());
}
}
<em> return $this;
}</em>
[/php]
Replace with
[php]
<em> public function preDispatch()
{
parent::preDispatch(); </em>
$allowGuest = Mage::helper(’review’)->getIsGuestAllowToWrite();
if (!$this->getRequest()->isDispatched()) {
return;
}
$action = $this->getRequest()->getActionName();
if (!$allowGuest && $action == ‘post’ ) {
if (!Mage::getSingleton(’customer/session’)->isLoggedIn()) {
$this->setFlag(’’, self::FLAG_NO_DISPATCH, true);
Mage::getSingleton(’customer/session’)->setBeforeAuthUrl(Mage::getUrl(’*/*/*’, array(’_current’ => true)));
$data = $this->getRequest()->getPost();
if(empty($data) ){
$data = Mage::getSingleton(’review/session’)->getFormData(true);
}
if(isset($data[’referrer’])){
Mage::getSingleton(’review/session’)->setFormData($data)
->setRedirectUrl($data[’referrer’]);
}else{
Mage::getSingleton(’review/session’)->setFormData($data)
->setRedirectUrl($this->_getRefererUrl());
}
$this->_redirectUrl(Mage::helper(’customer’)->getLoginUrl());
}
}
<em> return $this;
} </em>
[/php]