问题描述
我正在尝试在magento的产品评论中添加其他文本字段.看起来这可能需要保留在"review_detail"表中,但是除了在数据库中创建列并将字段添加到模板文件之外,我不确定如何添加此字段以便将其集成到审核系统.谁能引导我朝正确的方向走?
I'm trying to add an additional text field to magento's product review. It looks like maybe this would need to live in the 'review_detail' table, but beyond creating the column in the db and adding the field to the template file, I'm not sure how to add this field so that it will be integrated into the review system. Can anyone get me started in the right direction?
推荐答案
我在评论表单中添加了2个额外字段,只需转到frontend \ base \ default \ template \ review/form.phtml将两个字段添加为其他文本字段
I have added 2 extra field in review form just go to the frontend\base\default\template\review/form.phtml add two field as other text field.
现在转到app \ code \ core \ Mage \ Review \ Model \ Mysql4 \ Review.php
Now go to app\code\core\Mage\Review\Model\Mysql4\Review.php
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$detail = array(
'title' => $object->getTitle(),
'detail' => $object->getDetail(),
'nickname' => $object->getNickname(),
'email' => $object->getEmail(), // New field 1
'fname' => $object->getFname(), // New field 2
);
现在添加电子邮件,数据库中review_detail表中的名称也将转到app \ code \ core \ Mage \ Adminhtml \ Block \ Review \ Edit \ Form.php也添加:
Now add email,fname in the review_detail table in the database also go to app\code\core\Mage\Adminhtml\Block\Review\Edit\Form.php also add :
$fieldset->addField('fname', 'text', array( // New field 2
'label' => Mage::helper('review')->__('First Name'),
'required' => true,
'name' => 'fname'
));
$fieldset->addField('email', 'text', array( // New field 1
'label' => Mage::helper('review')->__('Email'),
'required' => true,
'name' => 'email'
));
之前
$fieldset->addField('nickname', 'text', array(
'label' => Mage::helper('review')->__('Nickname'),
'required' => true,
'name' => 'nickname'
));
我希望您现在可以在评论表单中添加其他字段.
I hope now you can add extra fields in review form.
谢谢
这篇关于在magento评论中添加其他文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!