【发布时间】:2012-01-18 11:18:42
【问题描述】:
我期待创建一个自定义模块,该模块添加一个输入字段以在评论表单中收集“电子邮件 ID”,但仅适用于访客客户。
我知道这可能需要重写一些核心模块,例如 '/code/core/Mage/Review/Model/Mysql4/Review/Product/Collection.php' 和 '/code/core/Mage/Review/Model/ Mysql4/Review.php' 并编辑块文件和 .phtml 文件以包含“电子邮件”文本字段。
还需要将新字段添加到数据库表中。并且该字段应该强制为访客客户提供。注册客户在发布评论时无需输入他们的电子邮件 ID。
所以我不知道如何去做以下事情: 1)哪些核心文件需要重写? 2)我应该如何在现有数据库表中添加这个新字段以进行“审查”,以便将来的升级不会覆盖它? 3) 我应该如何确保访客客户强制填写此字段? (注册用户不填也可以)
请,非常感谢任何帮助。谢谢。
这是我到目前为止所做的
CM
Review
Block
Review
Edit
Form.php
etc
config.xml
Helper
Data.php
Model
Resource
Review.php
Review
Product
Collection.php
这是我的 config.xml 的内容
<?xml version="1.0"?>
<config>
<modules>
<CM_Review>
<version>0.0.1</version>
</CM_Review>
</modules>
<frontend>
<routers>
<review>
<use>standard</use>
<args>
<module>CM_Review</module>
<frontName>Review</frontName>
</args>
</review>
</routers>
</frontend>
<global>
<blocks>
<adminhtml>
<rewrite>
<review_edit_form>CM_Review_Block_Review_Edit_Form</review_edit_form>
</rewrite>
</adminhtml>
</blocks>
<helpers>
<review>
<rewrite>
<class>CM_Review_Helper</class>
</rewrite>
</review>
</helpers>
<models>
<review>
<rewrite>
<resource_review>CM_Review_Model_Resource_Review</resource_review>
<resource_review_product_collection>
CM_Review_Model_Resource_Review_Product_Collection
</resource_review_product_collection>
</rewrite>
</review>
</models>
</global>
我重写的每个核心文件都是从原始 Review Model 文件和 Adminhtml/Block/Review Edit 文件扩展而来的。我复制粘贴了相同的代码,只是在我的代码中添加了额外的“电子邮件”字段.
我现在已经在数据库中手动添加了字段,并且在 base/defaut/review/form.phtml 中添加了输入字段,但它仍然没有将数据保存在表中。
但是,如果我尝试通过编辑核心文件来添加此字段,那么它会保存来宾客户的电子邮件 ID,并且可以正常工作。
无法弄清楚我做错了什么?
【问题讨论】:
-
有人对此有什么建议吗?我对如何执行此操作有一个模糊的想法,但我并不完全确定。如果有人能给出一份关于如何去做的路线图?
标签: php zend-framework magento