Magento - add a custom attribute (column) to the Sales_order index table

I have added a custom attribute to the table sales_order_flat, and I'm trying to display this attribute in a grid in sales_order/index.

I did this with client attributes successfully, but I get errors when trying to do the same with order data.

<global>
    <blocks>
        <adminhtml>
            <rewrite>
                <sales_order_grid>WACI_AdminHtmlExt_Block_Sales_Order_Grid</sales_order_grid>
            </rewrite>
        </adminhtml>
    </blocks>
 <!-- etc  -->

Application / code / local / namespace / module / Block / Sales / Order / Grid.php

class WACI_AdminHtmlExt_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{

    protected function _prepareColumns()
    {

        $this->addColumn('dynamics_ord', array(
            'header'    => $this->__('Dynamics ID'),
            'width'     => '75px',
            'index'     => 'dynamics_ord',
        ));

        $this->addColumnsOrder('dynamics_ord','entity_id');

        return parent::_prepareColumns();
    }
}

I see it is _prepareCollection sometimes used , but I'm trying to just change the collection in time setCollectionfor, if nothing more, simplicity.

In any case, the column is displayed, but no data is created. (And page errors when I try to sort).

Any ideas on this?

Update

SO. , . sales_flat_order, sales_flat_order_grid.

, , ( ).

- updateGridRecords() ?

= > updateGridRecords $order- > save() (- ).

, - , _prepareColumns - , .

= > yep. attr. Win!

+4
2

, Mage_Eav_Model_Entity_Collection_Abstract sales_flat_order_grid, Mage_Sales_Model_Resource_Abstract, EAV.

- , EAV - , , .

addAttributeToSelect, , Mage_Sales_Model_Resource_Collection_Abstract addFieldToSelect, dynamic_ord sales_flat_order_grid.

, EAV , Mage_Sales_Model_Resource_Order_Abstract:: updateGridRecords, sales_flat_order_grid, , sales_flat_order_grid, , dynamic_ord , script.

, install script, . , , .

, , , , , .

+4

EAV FLAT, . 4 , , , , ....!!!

0

All Articles