在我的项目中,我location
在管理面板的“产品评论”中添加了一个新字段,按照许多博客中的说明执行以下步骤。
- 在数据库表中创建了一个新字段
review_detail
为location
. 在中添加以下代码
app/code/code/Mage/Adminhtml/Block/Review/Edit/Form.php
$fieldset->addField('location', 'text', array( 'name' => 'location', 'label' => Mage::helper('adminhtml')->__('Location'), 'required' => false ) );
就在上面:
$fieldset->addField('nickname', 'text', array(
'label' => Mage::helper('review')->__('Nickname'),
'required' => true,
'name' => 'nickname'
));
.添加以下代码
app/code/core/Mage/Review/Model/Resource/Review.php
$detail = array( 'title' => $object->getTitle(), 'detail' => $object->getDetail(), 'nickname' => $object->getNickname(), 'location' => $object->getLocation() /* added */ );
在下面的函数数组中添加了“位置”。在文件中:
app/code/core/Mage/Review/Model/Resource/Review/Collection.php
protected function _initSelect() { parent::_initSelect(); $this->getSelect() ->join(array('detail' => $this->_reviewDetailTable), 'main_table.review_id = detail.review_id', array('detail_id', 'title', 'detail', 'nickname', 'customer_id','location')); return $this; }
在 中添加了以下内容
{$mytheme}/template/review/form.phtml
:<li> <label for="location_field" class="required"><em>*</em><?php echo $this->__('Location') ?></label> <div class="input-box"> <input type="text" name="nickname" id="location_field" class="input-text required-entry" value="<?php echo $this->htmlEscape($data->getLocation()) ?>" /> </div> </li>
我的问题是,虽然我可以在管理面板中看到一个新字段,但每当我提交评论表单时,它并没有被提交/存储在数据库中。
我什至重新索引并清除了缓存。
我应该进行哪些更改才能使其正常工作?
请帮忙......我在magento 1.8上。
PS:我知道核心文件不应该改变。一旦我在这个问题上取得成功,我将把它覆盖到新模块。