1

I am trying to add a new column to the sales order grid populated with data from an attribute in the customer_entity_varchar table. I have created the module and the new column is showing correctly:

<?php
class Sulman_SalesOrderGridExtender_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{

    protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel($this->_getCollectionClass());
        $select = $collection->getSelect();
        $collection->getSelect()->join(

            array('cev' => 'customer_entity_varchar'), 'cev.entity_id=main_table.customer_id', array('mycustomval' => 'value'))
            ->where('cev.attribute_id=191');

        $this->setCollection($collection);
        //echo $collection->getSelect();die;
        return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {
        $this->addColumn('mycustomval', array(
            'header'    =>  Mage::helper('customer')->__('mycustomval'),
            'width'     =>  '50px',
            'index'     =>  'mycustomval',
            'type'      =>  'text',
        ));

        // add column after grand_total column
        $this->addColumnsOrder('custom_message', 'mycustomval');

        return parent::_prepareColumns();
    }
}
?>

enter image description here

The issue is that the data is not displaying in the column.

Running the SQL directly shows the records with the value in them correctly. They are just not displaying in the column...

Any ideas? Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.