我正在遵循Ivan的教程(在订单网格中添加订单属性) Magento 1.4.1 )向sales_order_grid表中添加了一个额外的列(“运输说明”文本),并且它可以正常工作,只是没有将sales_flat_order中的旧数据带到sales_order_grid中的新列中。
我的SQL安装脚本添加 该列正确无误,因为我使用的名称与sales_flat_order中的字段名称相同,所以我认为不需要观察者,但是将所有现有货运描述数据导入shipping_description字段的代码未运行。
我做错了什么?
我的SQL安装脚本:
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社区版!
感谢您的帮助!