Skip to content

Order customer_email LIKE % condition doesn't work because of the Core Magneto Framework issue #39878

Open
@Genaker

Description

@Genaker
Contributor

Preconditions and environment

  • Magento version: all

  • Anything else that would help a developer reproduce the bug

          /* @var $collection AbstractCollection */ in my case order grid collection 
    

Magento\Sales\Model\ResourceModel\Order\Grid\Collection</
$collection->addFieldToFilter($field, ['LIKE' => $value . '%']);

/var/www/html/magento/vendor/magento/module-sales/Model/ResourceModel/Order/Grid/Collection.php

result is:

Image

if make like this :
$collection->addFieldToFilter($field, ['like' => $value . '%']);

it works. You need lower case if you are doing some stuff

it comes from the Zend ok but after some broken magneto code make from it not like but =

Image

i was too tired to test why magento is broken.

please check

Steps to reproduce

test

Expected result

like works

Actual result

like doesn't work

Additional information

No response

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
    Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
    Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
    Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
    Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Activity

m2-assistant

m2-assistant commented on May 1, 2025

@m2-assistant

Hi @Genaker. 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.


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 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.

Genaker

Genaker commented on May 1, 2025

@Genaker
ContributorAuthor

PR created: #39879

added
Reported on 2.4.xIndicates original Magento version for the Issue report.
Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it
on May 2, 2025
self-assigned this
on Jun 6, 2025
m2-assistant

m2-assistant commented on Jun 6, 2025

@m2-assistant

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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
    5. Add label Issue: Confirmed once verification is complete.
    6. Make sure that automatic system confirms that report has been added to the backlog.
engcom-Hotel

engcom-Hotel commented on Jun 6, 2025

@engcom-Hotel
Contributor

Hello @Genaker,

Thanks for the report and collaboration!

I've analyzed this issue thoroughly. It appears that there's a problem with the LIKE condition (when in uppercase) not functioning properly in Magento's order collection filtering.

We have tried to reproduce the issue in the latest development i.e. 2.4-develop via making a sample script as below;

Sample Script
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';

$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();

// Get order grid collection
$collection = $objectManager->create(\Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class);

$field = 'customer_email';
$value = 'order_80'; // Replace with the beginning of an email you know exists

// Method 1: Using uppercase 'LIKE'
$collection->addFieldToFilter($field, ['LIKE' => $value . '%']);

echo "SQL Query with UPPERCASE 'LIKE':\n";
echo $collection->getSelectSql(true) . "\n\n";
echo "Results count: " . $collection->count() . "\n\n";

// Reset collection
$collection = $objectManager->create(\Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class);

// Method 2: Using lowercase 'like'
$collection->addFieldToFilter($field, ['like' => $value . '%']);

echo "SQL Query with lowercase 'like':\n";
echo $collection->getSelectSql(true) . "\n\n";
echo "Results count: " . $collection->count() . "\n\n";

The output for the same is as follows:

SQL Query with UPPERCASE 'LIKE':
SELECT `main_table`.* FROM `sales_order_grid` AS `main_table` WHERE (((`main_table`.`customer_email` = 'order_80%')))

Results count: 0

SQL Query with lowercase 'like':
SELECT `main_table`.* FROM `sales_order_grid` AS `main_table` WHERE (`main_table`.`customer_email` LIKE 'order_80%')

Results count: 1

The issue seems reproducible for us. Hence confirming the issue.

Thanks

added
Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmed
Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch
and removed on Jun 6, 2025

11 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrameworkComponent: Framework/DBUSE ONLY for FRAMEWORK RELATED BUG!Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Reported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    Status

    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Genaker@thomas-kl1@engcom-Bravo@engcom-Hotel@github-jira-sync-bot

      Issue actions

        Order customer_email LIKE % condition doesn't work because of the Core Magneto Framework issue · Issue #39878 · magento/magento2