I working on Magento framework.
I want to rewrite Mage_Adminhtml_Block_Widget_Grid
to optimize search filtering.
I add rewrite block on my etc/config.xml
and name block as grid_search_date
.
<config>
<global>
<helpers>
<core>
<rewrite>
<data>Jdate_Format_Helper_Data</data>
</rewrite>
</core>
</helpers>
<blocks>
<grid_search_date>
<rewrite>
<widget_grid>Jdate_Format_Block_Widget_Grid</widget_grid>
</rewrite>
</grid_search_date>
<topmenu_admin_time>
<rewrite>
<widget_grid_column_renderer_date>Jdate_Format_Block_Widget_Grid_Column_Renderer_Date</widget_grid_column_renderer_date>
</rewrite>
</topmenu_admin_time>
</blocks>
</global>
</config>
You can see Jdate_Format_Block_Widget_Grid
want to rewrite widget_grid
and we move to this file
class Jdate_Format_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
protected function _addColumnFilterToCollection($column)
{
if ($this->getCollection()) {
$field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
if ($column->getFilterConditionCallback()) {
call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
} else {
$cond = $column->getFilter()->getCondition();
die(var_dump($cond["orig_from"]));
die(var_dump($cond["orig_to"]));
if ($field && isset($cond)) {
$this->getCollection()->addFieldToFilter($field , $cond);
}
}
}
return $this;
}
}
But nothing happen. But if I change directly Widget_Grid
file to this, it works.
Any idea?
Try