magento -- 在magento中如何回复客户的评论

转自:<a href="http://blog.csdn.net/alex748/archive/2009/08/06/4419814.aspx">alex748</a>

magento本身是不带 回复评论的功能的,现成的扩展(无论免费的还是商业的)也没找到,那就自己写一个吧,花了一下午写完,自我感觉不错,拿出来晾晾

1. 数据库中 review_detail 表新增字段 reply

magento -- 在magento中如何回复客户的评论

2. 修改Form.php 文件, 添加回复文本框, app/code/core/Mage/Adminhtml/Block/Review/Edit/Form.php 135

$fieldset->addField('reply', 'textarea', array(

'label' => Mage::helper('review')->__('Reply'),

'required' => false,

'name' => 'reply',

'style' => 'height:24em;',

));

3. 修改Review.php 文件, 添加表单获取字段, app/code/core/Mage/Review/Model/Mysql4/ Review.php 95

/**

* save detale

* //Alex add reply 2009-08-06

*/

if(!is_null($object->getReply())){

$reply=$object->getReply();

}else{

$reply='';

}

$detail = array(
'title' => $object->getTitle(),
'detail' => $object->getDetail(),
'nickname' => $object->getNickname(),
'reply' =>
$reply
);

4. 修改list.phtml 文件,增加回复输出,app/design/frontend/default/eshopstandard/template/review/product/view/list.phtml 56

<p><?php echo nl2br($this->htmlEscape($_review->getDetail())) ?> <?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?></p>

<?php //Alex add reply 2009-08-06 ?>

<p style="color: rgb(204, 0, 51);"><?php echo $this->__('Reply:') ?><?php echo nl2br($this->htmlEscape($_review->getReply())) ?></p>

完成!

相关文章: