【发布时间】:2015-10-02 22:31:38
【问题描述】:
我正在按照 Ivan 的教程 (Adding order attribute to the orders grid in Magento 1.4.1) 向 sales_order_grid 表(运输说明文本)添加一个额外的列,它可以正常工作,只是它不会将 sales_flat_order 中的旧数据带到 sales_order_grid 中的新列。
我的 SQL 安装脚本正确添加了该列,因为我使用的字段名称与 sales_flat_order 中的字段名称相同,所以我认为我不需要观察者,但是将所有现有运输描述数据导入到 shipping_description 字段中的代码没有运行。
我做错了什么?
我的 SQL 安装脚本:
<?php
/**
* Setup scripts, add new column and fulfills
* its values to existing rows
*
*/
/* @var $this Mage_Sales_Model_Mysql4_Setup */
$this->startSetup();
// Add column to grid table
$this->getConnection()->addColumn(
$this->getTable('sales/order_grid'),
'shipping_description',
"varchar(255) not null default ''"
);
// Add key to table for this field,
// it will improve the speed of searching & sorting by the field
$this->getConnection()->addKey(
$this->getTable('sales/order_grid'),
'shipping_description',
'shipping_description'
);
// fill existing rows with data
$select = $this->getConnection()->select();
$select->join(
array('order'=>$this->getTable('sales/order')),
$this->getConnection()->quoteInto('order.entity_id = order_grid.entity_id',''),
array('shipping_description' => 'shipping_description')
);
$this->getConnection()->query(
$select->crossUpdateFromSelect(
array('order_grid' => $this->getTable('sales/order_grid'))
)
);
$this->endSetup();
我正在使用 Magento 1.5.1 社区版!
感谢您的帮助!
【问题讨论】:
标签: magento