Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the possibility to search for null in backend grids #1203

Merged
merged 10 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ parameters:

-
message: "#^Call to an undefined method Varien_Data_Collection\\:\\:addFieldToFilter\\(\\)\\.$#"
count: 1
count: 2
path: ../app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

-
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ Most important changes will be listed here, all other changes since `19.4.0` can

### Between Magento 1.9.4.5 and OpenMage 19.x

- bug fixes and PHP 7.x and 8.0 compatibility
- bug fixes and PHP 7.x, 8.0 and 8.1 compatibility
- added config cache for system.xml [#1916](https://github.com/OpenMage/magento-lts/pull/1916)
- search for "NULL" in backend grids [#1203](https://github.com/OpenMage/magento-lts/pull/1203)

### Between OpenMage 19.x and 20.x

Expand Down
9 changes: 8 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,14 @@ protected function _addColumnFilterToCollection($column)
} else {
$cond = $column->getFilter()->getCondition();
if ($field && $cond !== null) {
$this->getCollection()->addFieldToFilter($field , $cond);
$filtered = array_map(static function ($value) {
return is_object($value) ? $value->__toString() : $value;
}, array_values($cond));
if (in_array('\'%NULL%\'', $filtered, true) || in_array('NULL', $filtered, true)) {
$this->getCollection()->addFieldToFilter($field, ['null' => true]);
} else {
$this->getCollection()->addFieldToFilter($field, $cond);
}
}
}
}
Expand Down