问题描述
我在sales_flat_order中添加了一个新列(已导出),并在以下位置添加了文件:
I have added a new column (exported)in sales_flat_order and add at files at this location:
app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass())
->addAttributeToSelect('*')
->joinAttribute('exported','sales/order','sales_flat_order.entity_id',null,'left');
}
protected function _prepareColumns()
{
$this->addColumn('exported', array(
'header' => Mage::helper('sales')->__('Exported'),
'index' => 'exported',
'type' => 'checkbox',
'name' =>'exported',
'value' =>$this->getExported()==1 ? 'true' : 'false',
));
}
之后,它显示在管理站点的订单网格上,但不显示值和名称,
after that it showing on order grid in admin site,but it is not showing value and name,
我是magento的新手,所以请帮助我,停留2天.感谢您的协助.
I am new in magento,so please help me ,stuck from 2 days.Thanks for Assistance.
推荐答案
方法_prepareCollection()使用sales_flat_order_grid表作为源,因此您必须将该列添加到sales_flat_order_grid表中并从适当的列中更新该列的值sales_flat_order表.
The method _prepareCollection() uses sales_flat_order_grid table as asource, thus you have to add the column to sales_flat_order_grid table and update the values of that column from the appropriate column of sales_flat_order table.
在这种情况下,Magento将自动更新sales_flat_order_grid表中的此列以用于将来的订单.
In this case, Magento will automatically update this column in sales_flat_order_grid table for future orders.
显示布尔列的更好方法是是/否"渲染器.为此,请在_prepareColumns()方法中使用以下代码
The better way to display the boolean column is Yes/No renderer. Use the following code for this in _prepareColumns() method
$this->addColumn('exported', array(
'header' => Mage::helper('sales')->__('Exported'),
'index' => 'exported',
'type' => 'options',
'width' => '70px',
'options' => array(
1 => Mage::helper('sales')->__('Yes'),
0 => Mage::helper('sales')->__('No'),
),
));
还有其他一些有用的文章,它们将订单网格定制化.查看以下链接:
There are some other useful articles about cutomizing order grid. Check out the links below:
- http://inchoo.net/ecommerce/magento /how-to-extend-magento-order-grid/
- http://www.ecomdev.org/2010/07/27/adding-order-attribute-to-orders-grid-in-magento-1-4-1.html
- http ://www.demacmedia.com/magento-commerce/mini-tutorial-adding-column-to-orders-grid-in-magento-backend/
- http://www.atwix.com/magento/column-to -orders-grid/
- http://inchoo.net/ecommerce/magento/how-to-extend-magento-order-grid/
- http://www.ecomdev.org/2010/07/27/adding-order-attribute-to-orders-grid-in-magento-1-4-1.html
- http://www.demacmedia.com/magento-commerce/mini-tutorial-adding-column-to-orders-grid-in-magento-backend/
- http://www.atwix.com/magento/column-to-orders-grid/
这篇关于在sales_flat_order中添加并显示新列,并将其显示在magento的订单网格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!