A-A+

Magento开启登陆发表评论不好使,游客依然能评论怎么办?

2012年08月31日 灵犀一指 Magento开启登陆发表评论不好使,游客依然能评论怎么办?已关闭评论 阅读 991 人 次

这其实是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]

 

评论已关闭!