-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Conversation
I tried but it does not work on our websites, I did that: $filtered = array_map(static function ($value) {
return is_object($value) ? $value->__toString() : $value;
}, is_array($cond) ? array_values($cond) : [$cond]);
if (in_array('\'%NULL%\'', $filtered, true) || in_array('NULL', $filtered, true)) {
$this->getCollection()->addFieldToFilter($field, ['null' => true]);
} else {
$this->getCollection()->addFieldToFilter($field, $cond);
} In my test, $cond contains Zend_Db_Expr. |
I still using my version, but not really used because I forgot that now I can search with NULL :) |
@luigifab should we push your version to this PR? |
Why not. |
done, hope correctly :-) |
This one is failing again with PHPStan. |
PHPStan is wrong! Where is the support? 😸 |
This PR is useful only when there are no data on a column of a Backend grid. I can get this information by one click on column title. Of course is a difference between a sort and a filtering action. It is easier to do mass-actions with filtered information (Select All). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and worked. @tobihille Thanks for the bump.
somebody understands what phpstan is complaining about? |
@fballiano It's caused by the docblock here: magento-lts/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php Lines 286 to 294 in fb601b0
It should be * @return Varien_Data_Collection_Db But I am not sure what should be done to fix that in this PR. [edit] Also
|
This would work, but not sure if its a good idea ... will check tomorrow
|
@sreichel did you have time to check this? |
Yes, fix phpstan-baseline.neon ... change count 1 to 2 for now. Its just a workaround, but removing this supressed errors is what i frequently do ... it will be fixed later ....
|
@digitalpianism i'm also confused. 47e461c was okay. All checks passed. I've reverted this change. |
Problem found: 2214b17 reverted all changes. I'll fix this in the evening ... (reapply fix) |
My bad, sorry about that. Please let me know what I did wrongly. |
@kiatng i dont know. I guess you just used the "Update branch" button. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test on customer grid, works
(but we should add something to the README) |
You successfully tested it, its your job :P |
fair enough 🤣 |
This comment has been minimized.
This comment has been minimized.
1 similar comment
The committed version is wrong if I remember correctly (not tested again). We need: |
I have this in production (I needed this exact feature). I have searched for |
I cannot test the above because I do not have customer reviews. But filtering for |
Looking at the code: magento-lts/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php Lines 499 to 503 in 712a3ee
If
When searching for all the The function return either magento-lts/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Checkbox.php Lines 53 to 65 in 712a3ee
and But I have not seen a grid column that uses checkbox or radio (checkboxes in massaction doesn't count). So what do we do? |
Tested with sample data and @luigifab is right. PR incoming. |
This is what happens on customer review page + filter. :) |
I overlooked that it is possible to define your own filter: magento-lts/app/code/core/Mage/Adminhtml/Block/Review/Grid.php Lines 147 to 153 in 5d9036e
And it returns magento-lts/app/code/core/Mage/Adminhtml/Block/Review/Grid/Filter/Type.php Lines 41 to 51 in 5d9036e
|
Maybe this could have been easier with correct phpdocs .... I'm working on this :) |
Description (*)
This modification will let users search for NULL entries in the backend grids.
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)