【发布时间】:2013-12-22 12:22:04
【问题描述】:
在我的项目中,我在管理面板的“产品评论”中添加了一个新字段 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 */ ); -
在下面的函数数组中添加了“location”。文件中:
app/code/core/Mage/Review/Model/Resource/Review/Collection.phpprotected 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:我知道核心文件不应该更改。一旦我在这个问题上取得成功,我将把它覆盖到新模块。
【问题讨论】:
标签: php magento magento-1.8