-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
OrderGridCollectionFilter Plugin Breaks Mapping for created_at
Column
#36439
Comments
Hi @nwcasebolt. Thank you for your report.
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
For more details, review the Magento Contributor Assistant documentation. Add a comment to assign the issue: To learn more about issue processing workflow, refer to the Code Contributions.
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
I also found it an hour ago. It's impossible that people that make such mistakes are working for a corporation like Adobe. |
Despite the name of the plugin referencing the order collection, the plugin is on a more generic class, so it can affect just about any UI admin grid that joins a table with "created_at". On my installation, I experienced this error on the customer grid (because we customized it to join the B2B company table) as well as a third party module table that was joining the quote table. I fixed it by patching \Magento\Sales\Plugin\Model\ResourceModel\Order\OrderGridCollectionFilter and removing these lines:
That allows it to call through to $proceed and execute all of the normal code. |
Hi @nwcasebolt, I was also getting the error related to 'created_at' column when trying to apply "purchase date" filter on order grid. I have created below patch to fix this issue. I was not unable to upload with '.patch' extension. So, the '.txt' extension can be changed to '.patch'. Then the patch can be directly applied to Magento setup. Patch-Fixed-CreatedAt-Filter-Issue-At-OrderGrid.txt Thanks, |
Hi @nwcasebolt, Thank you for reporting and collaboration. Steps to reproduce 1.Add an afterSearch plugin on Magento\Framework\View\Element\UiComponent\DataProvider\Reporting that joins the sales_order table to the sales_order_grid table.
2.Filter the Order grid on purchase date. We are getting a message "Something went wrong with processing the default view and we have restored the filter to its original state" Hence Confirming the issue. Thanks. |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-7684 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Bravo. Thank you for verifying the issue. |
For me replacing: |
@magento I am working on this |
Hi @engcom-Bravo. Thank you for working on this issue.
|
Hi @nwcasebolt, We have noticed that this issue has not been updated since long time. Hence we assume that this issue is fixed now, so we are closing it. Please feel to raise a fresh ticket or reopen this ticket if you need more assistance on this. Thanks. |
I also ran into this problem. Because my custom grid was joining some other tables with created_at. I resolved it by creating a before plugin for:
In this way the original plugin won't be affected. And in this before plugin you can check if the searchResult is an instance of the desired collection. And to eventually not hit the original around plugin, just add the table to the created_at field like: |
index 995bb83..3765a1d 100644
--- a/Plugin/Model/ResourceModel/Order/OrderGridCollectionFilter.php
+++ b/Plugin/Model/ResourceModel/Order/OrderGridCollectionFilter.php
@@ -52,7 +52,7 @@ class OrderGridCollectionFilter
}
}
- $fieldName = $subject->getConnection()->quoteIdentifier($field);
+ $fieldName = $subject->getConnection()->quoteIdentifier($field === 'created_at' ? 'main_table.created_at' : $field);
$condition = $subject->getConnection()->prepareSqlCondition($fieldName, $condition);
$subject->getSelect()->where($condition, null, Select::TYPE_CONDITION);
Here is a quick patch for getting it to work with any custom made that joins another tables that contains |
The issue is still present in 2.4.6-p3, your test are wrong. |
For anyone else looking for a fix, please see here: |
Preconditions and environment
Steps to reproduce
afterSearch
plugin onMagento\Framework\View\Element\UiComponent\DataProvider\Reporting
that joins thesales_order
table to thesales_order_grid
table.Example:
Expected result
The orders are filtered by purchase date.
Actual result
Additional information
A bug was introduced in 2.4.5 when the OrderGridCollectionFilter plugin was added in December 2021 to convert the
created_at
field to UTC. The plugin'saroundAddFieldToFilter
filter returns the field without calling$proceed
. This means thatcreated_at
never gets processed through\Magento\Framework\Data\Collection\AbstractDb::addFieldToFilter
, which in turns preventscreated_at
from getting mapped tomain_table
.It's also worth pointing out that the new plugin duplicates code which operates on
created_at
in\Magento\Sales\Model\ResourceModel\Order\Grid\Collection::addFieldToFilter
, leaving everything in that collection's if statement unreachable.Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: