Skip to content

Commit 58c3ae8

Browse files
committed
Updated the code from luigifab comments
1 parent dafa2ba commit 58c3ae8

File tree

1 file changed

+6
-3
lines changed
  • app/code/core/Mage/Adminhtml/Block/Widget

1 file changed

+6
-3
lines changed

app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,14 +461,17 @@ protected function _setFilterValues($data)
461461
protected function _addColumnFilterToCollection($column)
462462
{
463463
if ($this->getCollection()) {
464-
$field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
464+
$field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
465465
if ($column->getFilterConditionCallback() && $column->getFilterConditionCallback()[0] instanceof self) {
466466
call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
467467
} else {
468468
$cond = $column->getFilter()->getCondition();
469469
if ($field && isset($cond)) {
470-
if (in_array('NULL', array_values($cond), true)) {
471-
$this->getCollection()->addFieldToFilter($field, array('null' => true));
470+
$filtered = array_map(static function ($value) {
471+
return is_object($value) ? $value->__toString() : $value;
472+
}, array_values($cond));
473+
if (in_array('\'%NULL%\'', $filtered, true) || in_array('NULL', $filtered, true)) {
474+
$this->getCollection()->addFieldToFilter($field, ['null' => true]);
472475
} else {
473476
$this->getCollection()->addFieldToFilter($field, $cond);
474477
}

0 commit comments

Comments
 (0)