Magento-将字段添加到sales_flat_quote [英] Magento - add field to sales_flat_quote

查看:124
本文介绍了Magento-将字段添加到sales_flat_quote的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个模块,该模块需要将一个附加字段添加到sales_flat_quote表/模型中.

I have created a module which requires an additional field to be added to the sales_flat_quote table / model.

在我的安装脚本中,一切似乎都可以正常工作,并且可以在数据库中看到新字段.

Everything appears to work fine in my install script and the new field can be seen in the database.

当检索报价对象并针对我的新字段存储值时,该值永远不会记录到数据库中. save方法不会产生错误或异常,但该值永远不会消失.

When retrieving a quote object and storing a value against my new field the value never gets recorded to the database. The save method doesnt product an error or exception but the value never sticks.

如果有所作为,我试图在结帐过程中将值保存到观察者的报价中.

If it makes a difference, I am trying to save the value to the quote from an observer, during the checkout process.

这是我在安装脚本中使用的代码:

Here is the code I am using in my install script:

$setup = new Mage_Sales_Model_Mysql4_Setup('sales_setup');
$setup->getConnection()->addColumn(
        $setup->getTable('sales_flat_quote'),
        'test_attribute',
        'text NULL DEFAULT NULL'
    );

$setup->addAttribute('quote', 'test_attribute', array('type' => 'text', 'visible' => false));

我在这里错过了明显的东西吗?

Am I missing something obvious here?

推荐答案

不知道为什么创建此对象$setup = new Mage_Sales_Model_Mysql4_Setup('sales_setup'); 例如,如果您查看\ app \ code \ core \ Mage \ Sales \ sql \ sales_setup \ mysql4-upgrade-1.3.99-1.4.0.0.php,您将看到:

Don't know why you create this object $setup = new Mage_Sales_Model_Mysql4_Setup('sales_setup'); If you look for example into \app\code\core\Mage\Sales\sql\sales_setup\mysql4-upgrade-1.3.99-1.4.0.0.php, you will see:

/* @var $installer Mage_Sales_Model_Entity_Setup */
$installer = $this;
$installer->startSetup();

/* Include code from mysql4-upgrade-0.9.38-0.9.39.php */
$installer->getConnection()->addColumn($installer->getTable('sales_flat_quote_item'),
    'store_id', 'smallint(5) unsigned default null AFTER `product_id`');

当然,您应该删除缓存,将config.xml中的模块版本更改为大于core_resource表中模块的版本.

And of course you should delete cache, change your module version in config.xml to number bigger than you have for you module in core_resource table.

这篇关于Magento-将字段添加到sales_flat_quote的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆