我正在尝试添加自定义字段到magento结帐onepage。我遵循了一个在1.4.1中不起作用的示例,因为移动到了一个平面订单表(我认为) http://inchoo.net/ecommerce/magento/adding-a-new-tab-under-one-page-checkout-full-working-module/
我可以在结帐页面中看到我的自定义选项卡和我的自定义字段,但是我无法将这些字段保存到数据库中。
中添加元素吗?
谢谢
发布于 2010-08-22 18:13:35
免责声明:我已经6个月没有碰过Magento了。现在,如果您查看app/code/core/Mage/Sales/sql/sales_setup/目录,就会发现如何修改订单表的示例。例如,这里是app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.12-0.9.13.php的内容(没有头注释):
$installer = $this;
/* @var $installer Mage_Sales_Model_Mysql4_Setup */
$installer->addAttribute('quote', 'subtotal', array('type'=>'decimal'));
$installer->addAttribute('quote', 'base_subtotal', array('type'=>'decimal'));
$installer->addAttribute('quote', 'subtotal_with_discount', array('type'=>'decimal'));
$installer->addAttribute('quote', 'base_subtotal_with_discount', array('type'=>'decimal'));根据config/global/resources/sales_setup/setup/class后面的app/code/core/Mage/Sales/etc/config.xml初始化$this,您将看到它从Mage_Eav_Model_Entity_Setup (默认的安装类)继承,并重写或添加一些方法(例如,对于平面表的支持)。
要回答第一点(第一个问题),可以使用该类的addAttribute()方法添加列。第二个问题的答案是肯定的,但您必须在模块的config.xml文件中指定要使用Mage_Sales_Model_Mysql4_Setup作为安装类。这是通过添加之前在app/code/core/Mage/Sales/etc/config.xml中找到的相同的xml元素来实现的(将sales_setup替换为yourmod_setup)。因此,转储数据库,在mysql4-install-0.1.0.php文件中使用get_class($this)检查它的工作情况,然后恢复db。然后继续在安装文件中编写,从app/code/core/Mage/Sales/sql/sales_setup中看到的文件中鼓舞自己,这应该会很好!第二点..。我不知道。我希望它能自动工作!祝好运!
https://stackoverflow.com/questions/3537725
复制相似问题