需要给自己的站review form增加一个email字段和reply字段.为了自己以后查找,特别记录下:
首先是手工增加字段,直接在review下增加就好.
由于我用的是Magento1.6,所以下面代码部分位置可能稍微有点不一样.
Review/Model/Resource/Review.php

protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$detail = array(
'title' => $object->getTitle(),
'detail' => $object->getDetail(),
'nickname' => $object->getNickname(),
'email' => $object->getEmail(), // 新增的email字段
'reply' => $object->getReply(), // 新增的reply字段
);

这样,前台就可以post新建的email字段,并保存进数据库了.
由于有reply字段,所以我需要可以在后台也增加一个.
Review\Edit\Form.php

$fieldset->addField('reply', 'text', array( // New field 1
'label' => Mage::helper('review')->__('reply'),
'required' => true,
'reply' => 'reply'
));

这样在进去review的编辑界面的时候,就可以显示并且保存该字段.

现在两个字段保存都是没有问题了.但是现在会有一个问题,那就是前台list不显示reply字段
okay..只需要把reply字段加进控制器就好
(默认情况下,是没有select新加的字段进去的.所以需要修改Model把字段加进去.)
Review/Model/Resource/Review/Product/Collection.php
具体也忘了自己加的哪些了…自己看吧…
Magento Connect其实也有类似的插件.不过是收费的,而且功能太多.我只需要一个简单点的功能:有email,reply字段,还有验证码,不需要批准就能显示review..
所以自己写就好了… 还是建议大家能买插件就买..自己写挺费时间的
参考文章:http://www.magentocommerce.com/boards/viewthread/264533/

关于作者

专注于电商,magentochina站长
shuai.zend一共有81篇博文

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

TOP Online Store
1.Girls' Generation, a Fantasy Jewelry online Store. Nobody Can Keep Away From the Beauty:tiffany ca 2.China Wholesale Electronics:China Wholesale Electronics 3.The android phone is best:Android sale.The Android Ice cream sandwich well be best Android OS. 4.R4 3DS for sale:R4 ds shops,and support Japanese R4:R4 販売. 5.fashion bag:armani watches and MBT shoes.
R4 V1.4.2 and your R4i Gold 1.4.2 and R4i GOLD 3DS card V1.4.2 can not work on it.
Please update your R4i Gold 1.4.2 and R4i GOLD 3DS card V1.4.2 card with this patch. Please read readme.txt attached firstly.Just do as the procedures listed in readme.