Open dchaykas opened 1 month ago
Hi @dchaykas. Thank you for your report. To speed up processing of this issue, 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:
@magento give me 2.4-develop instance
- upcoming 2.4.x release@magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: 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.
Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.Issue: Confirmed
once verification is complete. Hello @dchaykas,
Thanks for the report and collaboration!
We have tried to reproduce the issue in the latest development branch i.e. 2.4-develop but it seems the issue is not reproducible for us.
Please find below the module for reference and let us know if we missed anything:
https://github.com/engcom-Hotel/magento2/tree/issue39000/app/code/Magz/Issue39000
Thanks
Thank you for the quick tetst @engcom-Hotel , please update the report logic to use UIComponent:
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<plugin name="orderGridCollectionFilterPlugin" type="Magento\Sales\Plugin\Model\ResourceModel\Order\OrderGridCollectionFilter"/>
</type>
The above code is the snippet where order plugin will catch all fields named created_at
preventing code from continue to mapper logic.
public function aroundAddFieldToFilter(
SearchResult $subject,
\Closure $proceed,
$field,
$condition = null
) {
if ($field === 'created_at' || $field === 'order_created_at') {
if (is_array($condition)) {
foreach ($condition as $key => $value) {
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
}
}
$fieldName = $subject->getConnection()->quoteIdentifier($field);
$condition = $subject->getConnection()->prepareSqlCondition($fieldName, $condition);
$subject->getSelect()->where($condition, null, Select::TYPE_CONDITION);
return $subject;
}
return $proceed($field, $condition);
}
I'll update the description, my bad for missing this piece.
Hello @dchaykas,
Thanks for the updates!
The issue is now reproducible after making the changes with the latest updates. Hence confirming the issue.
Thanks
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12771 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Preconditions and environment
This commit introduces a "aroundAddFieldToFilter" plugin which diverts the logic from using created mappings using "addFilterToMap" function for all columns in custom joins labeled as "created_at".
Steps to reproduce
Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
, setting main table assales_creditmemo_item
created_at
column.created_at
column, like this$this->addFilterToMap('created_at', 'creditmemo.created_at');
created_at
column.SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in where clause is ambiguous
Expected result
The
addFilterToMap
function should add the appropriate mapping alias to the joined table. The system should recognize the mapping and render the report with filters correctly. In the current bug the WHERE clause should have thecreditmemo.created_at
column as a filter instead ofcreated_at
.Actual result
Error shown:
Due to the missed mapping logic the code assumes the
created_at
potentially belongs to the main table (which creditmemo item table doesn't have) and throws an error if more tables joined having the same column name ascreated_at
.The plugin below intercepts mapper logic when fields name is
created_at
:vendor/magento/module-sales/etc/adminhtml/di.xml:52
The IF condition in the plugin does not use mapper logic to determine if a field has been mapped to something else:
For all other field names the plugin is skipped and go to the
$proceed(...)
call which continues to evaluate mapper fields code.Additional information
Release note
No response
Triage and priority