I had created 4 custom fields for the Order:
pgs_order_website_names
pgs_aramex_reference
pgs_aramex_shipped
pgs_aramex_shipped_date
I had copied Grid.php to local/Mage/
class Mage_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
Constructor
public function __construct()
{
parent::__construct();
$this->setId('sales_order_grid');
$this->setUseAjax(true);
$this->setDefaultSort('created_at');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
}
The _prepareCollection() Method :
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$select = $collection->getSelect();
$select->joinLeft(array(
'order' => Mage::getModel('core/resource')->getTableName('sales/order')),
'order.entity_id=main_table.entity_id',
array(
'pgs_order_website_names' => 'pgs_order_website_names',
'pgs_aramex_reference'=>'pgs_aramex_reference',
'pgs_aramex_shipped'=>'pgs_aramex_shipped',
'pgs_aramex_shipped_date'=>'pgs_aramex_shipped_date'
)
);
$this->setCollection($collection);
return parent::_prepareCollection();
}
The _prepareColumns() Method
protected function _prepareColumns()
{
$this->addColumn('pgs_order_website_names', array(
'header'=> Mage::helper('sales')->__('Ordered Websites'),
'index' => 'pgs_order_website_names',
'width' => '80px',
'type' => 'text',
'filter' => false,
));
$this->addColumn('pgs_aramex_reference', array(
'header'=> Mage::helper('sales')->__('Aramex ref. No'),
'index' => 'pgs_aramex_reference',
'width' => '80px',
'type' => 'text',
'filter' => false,
));
$this->addColumn('pgs_aramex_shipped', array(
'header'=> Mage::helper('sales')->__('Sent to Warehouse ?'),
'index' => 'pgs_aramex_shipped',
'width' => '80px',
'type' => 'text',
'filter' => false,
));
$this->addColumn('pgs_aramex_shipped_date', array(
'header'=> Mage::helper('sales')->__('Sent to Warehouse ?'),
'index' => 'pgs_aramex_shipped_date',
'width' => '80px',
'type' => 'date',
'filter' => false,
));
return parent::_prepareColumns();
}
Everythig is working fine if i make the 'filter' attribute to false in $this->addColumn()
Method! But if i changed to true im getting an error :
Fatal error: Call to a member function setColumn() on a non-object The column attributes are :
$dateAttribute = array(
'type' => 'date',
'backend_type' => 'date',
'frontend_input' => 'date',
'is_user_defined' => true,
'label' => 'Shipped date',
'visible' => true,
'required' => false,
'user_defined' => false,
'searchable' => false,
'filterable' => true,
'comparable' => false,
);
Magento CE 1.9
__construct()
method look like? Also make sure you are setting to use AJAX in the construct$this->setUseAjax(true);
Normally filterable is default astrue
more than likely you're missing a defined index in your collection or a callback function to sort in the collection. magento.stackexchange.com/a/118022/69main_table
.*,order
.pgs_order_website_names
,order
.pgs_aramex_reference
,order
.pgs_aramex_shipped
,order
.pgs_aramex_shipped_date
FROMsales_flat_order_grid
ASmain_table
LEFT JOINsales_flat_order
ASorder
ON order.entity_id=main_table.entity_id WHERE (increment_id
LIKE '%2800%') ORDER BY created_at DESC LIMIT 20