在Magento中,如何使用sales_order_数据填充sales_order_网格中的新列?
我按照Ivan的教程()在sales_order_网格表(发货说明文本)中添加了一个额外的列,它工作正常,只是没有将旧数据从sales_flat_order带到sales_order_网格中的新列 我的SQL安装脚本正确地添加了列,因为我使用的字段名与sales_flat_order中的字段名相同,我认为我不需要观察者,但是将所有现有装运描述数据导入装运描述字段的代码没有运行 我做错了什么 我的SQL安装脚本:在Magento中,如何使用sales_order_数据填充sales_order_网格中的新列?,magento,Magento,我按照Ivan的教程()在sales_order_网格表(发货说明文本)中添加了一个额外的列,它工作正常,只是没有将旧数据从sales_flat_order带到sales_order_网格中的新列 我的SQL安装脚本正确地添加了列,因为我使用的字段名与sales_flat_order中的字段名相同,我认为我不需要观察者,但是将所有现有装运描述数据导入装运描述字段的代码没有运行 我做错了什么 我的SQL安装脚本: <?php /** * Setup scripts, add new col
<?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();
这应该可以:
$select = $this->getConnection()->select();
$select->join(
array('order_shipping'=>$this->getTable('sales/order')),//alias=>table_name
$this->getConnection()->quoteInto(
'order_shipping.entity_id = order_grid.entity_id',
Mage_Sales_Model_Quote_Address::TYPE_SHIPPING
),//join clause
array('shipping_description' => 'shipping_description')//fields to get
);
$this->getConnection()->query(
$select->crossUpdateFromSelect(
array('order_grid' => $this->getTable('sales/order_grid'))
)
);
如果需要,请查看我的:)
好极了!当我试图把我的扩展放在一起时,我已经看过了你的扩展,在Ivan的帖子和你的扩展之间,我非常接近-只是填充数据时弄错了:-)我以后一定会开放我的超级简单版本。谢谢实际上,我需要销售订单网格中的一个字段warehouse,我在sales\u flat\u order和sales\u flat\u order\u网格表中创建了列名warehouse,并创建了属性:warehouse with values//count$this->addColumn('warehouse',array('header'=>Mage::helper('sales')->,'index'=>'warehouse','type'=>'options','width'=>'70px','options'=>Mage::getSingleton('eav/config')->getAttribute('catalog_product','warehouse'),);仍然不起作用,我需要执行任何步骤吗?列名称显示在销售订单网格上,而值不显示,在下订单后,我需要更改仓库值,最初名称应显示为“选择订单”我的属性:你能帮我做点什么吗?@Rathinam如果你想寻求帮助,你应该提出你自己的问题