服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > magento教程 >

Magento评论拒绝spam

时间:2016-05-12 09:54来源: 作者: 点击:
相信很多使用Magento的朋友都有这个问题,最模板zuimoban网站模板的另外一个站。产品评论已经过万,虽然大部分都是垃圾.这些Spam浪费我的时间,浪费我的精力,还让我的magento越来越慢

相信很多使用Magento的朋友都有这个问题,最模板zuimoban网站模板的另外一个站。产品评论已经过万,虽然大部分都是垃圾.这些Spam浪费我的时间,浪费我的精力,还让我的magento越来越慢,所以决定消灭他们.

好了,我们现在来解决这个问题。其实解决这个问题很简单。也有多种处理办法:

1.采用验证码,Magento connect中有给Magento review增加验证码的插件。记得有一个免费和一个收费的。

2.自己通过修改代码拒绝review spam。目前MagentoChina就是这么做的,直接让Magento判断游客提交的review中,是否带有http这个关键词。如果有,则报错。修改起来很简单,下面是代码:

代码位置在:app/code/core/Mage/Review/Model/Review.php

然后把这个文件Copy到:app/code/local/Mage/Review/Model/Review.php

然后在validate()这个方法中增加:

if (stristr($this->getDetail(), 'http')) {
$errors[] = $helper->__('Pls Don\'t Spam');
}

最后整个方法看起来像这样:

public function validate()
{
$errors = array();
 
$helper = Mage::helper('customer');
 
if (!Zend_Validate::is($this->getTitle(), 'NotEmpty')) {
$errors[] = $helper->__('Review summary can\'t be empty');
}
 
if (!Zend_Validate::is($this->getNickname(), 'NotEmpty')) {
$errors[] = $helper->__('Nickname can\'t be empty');
}
 
if (!Zend_Validate::is($this->getDetail(), 'NotEmpty')) {
$errors[] = $helper->__('Review can\'t be empty');
}
if (stristr($this->getDetail(), 'http')) {
$errors[] = $helper->__('Pls Don\'t Spam');
}
 
if (empty($errors)) {
return true;
}
return $errors;
继续
(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容