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

Magento2.4 GraphQL CustomerOrders Query Logic #31537

Closed
4 tasks
LouisFangAligentConsulting opened this issue Jan 5, 2021 · 25 comments · Fixed by #36036
Closed
4 tasks

Magento2.4 GraphQL CustomerOrders Query Logic #31537

LouisFangAligentConsulting opened this issue Jan 5, 2021 · 25 comments · Fixed by #36036
Assignees
Labels
Area: APIs Component: GraphQL GraphQL Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Project: GraphQL Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@LouisFangAligentConsulting

Preconditions (*)

1.Magento2.4.0
2.GraphQL

Steps to reproduce (*)

1.Create a new Module HelloWorld.
2.Create a schema.graphqls in HelloWorld/Sales/etc/ folder to extend the CustomerOrderFilterInput.
Put following codes in this file:

input CustomerOrdersFilterInput @doc(description: "Identifies the filter to use for filtering orders.") {
    created_at: FilterRangeTypeInput @doc(description: "Filters by created at.")
}

input FilterRangeTypeInput @doc(description: "Defines a filter that matches a range of values, such as prices or dates.") {
    from: String @doc(description: "The beginning of the range")
    to: String @doc(description: "The end of the range")
}

3.Use the following payload and {{your URL}}/graphql to query the customer token.

mutation {
  generateCustomerToken(email: "{{your email address}}", password: "{{your password}}") {
    token
  }
}

4.Put above token in Postman Headers Authorization with Bearer {{your token}}.
5.Use following payload to query the above customer's sales orders.

query {
    customer {
        orders(filter: { 
            created_at: { 
                from: "2021-01-02"
                to: "2021-01-04"
            }}) { 
            items { 
                number  
                created_at 
            }
        }
    }
}

6.The above query will get the result of all orders from 2021-01-02 or to 2021-01-04, not between 2021-01-02 and 2021-01-04.

Expected result (*)

1.What I expect is that the orders between 2021-01-02 and 2021-01-04.

Actual result (*)

1.The actual result is that the orders from 2021-01-02 or to 2021-01-04.
2.OrderFilter.php file makes filter conditions in the same filterGroups item and the relationship is OR. Maybe it is not a bug, but generally every condition should be in a separate filterGroups which relationship is AND. More ideally, in graphQL payload, some style like and: "true" can be provided to make a different logic combination.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • 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”.
@m2-assistant
Copy link

m2-assistant bot commented Jan 5, 2021

Hi @LouisFangAligentConsulting. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ 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, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@Santoshziffity
Copy link

@magento I am working on this

@m2-assistant
Copy link

m2-assistant bot commented Jan 19, 2021

Hi @Santoshziffity! 👋
Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

@Santoshziffity
Copy link

@magento add to contributors team

@m2-assistant
Copy link

m2-assistant bot commented Jan 19, 2021

Hi @Santoshziffity! 👋
Thank you for joining. Please accept team invitation 👉 here 👈 and add your comment one more time.

@m2-community-project m2-community-project bot added this to Ready for Development in GraphQL Backlog Feb 4, 2021
@m2-community-project m2-community-project bot removed this from Ready for Confirmation in Issue Confirmation and Triage Board Feb 4, 2021
@magento-engcom-team magento-engcom-team added this to Ready for Confirmation in Issue Confirmation and Triage Board Nov 8, 2021
@m2-community-project m2-community-project bot removed this from Ready for Development in GraphQL Backlog Nov 8, 2021
@engcom-Hotel engcom-Hotel self-assigned this Nov 19, 2021
@m2-assistant
Copy link

m2-assistant bot commented Nov 19, 2021

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).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - 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
Copy link
Contributor

Hello @LouisFangAligentConsulting,

We have tried to reproduce this issue in Magento 2.4-develop branch and it is reproducible for us while extending. To reproduce this issue we have followed the steps mentioned in the main description as well as enabling DB logs via the command bin/magento dev:query-log:enable.

I am attaching the db.log related to that query with the stack trace. It will help the developer in fixing the issue.
db.log

Thanks

@engcom-Hotel engcom-Hotel added Area: APIs Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reported on 2.4.x Indicates original Magento version for the Issue report. labels Nov 19, 2021
@github-jira-sync-bot
Copy link

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

@github-jira-sync-bot github-jira-sync-bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Nov 19, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Nov 19, 2021
@m2-community-project m2-community-project bot moved this from Confirmed to Ready for Confirmation in Issue Confirmation and Triage Board Nov 19, 2021
@m2-community-project m2-community-project bot added Issue: ready for confirmation Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: ready for confirmation labels Nov 19, 2021
@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Nov 19, 2021
@serbynskyi
Copy link
Contributor

@magento I am working on this

@m2-assistant
Copy link

m2-assistant bot commented Aug 15, 2022

Hi @serbynskyi! 👋
Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

@serbynskyi
Copy link
Contributor

@magento add to contributors team

@m2-assistant
Copy link

m2-assistant bot commented Aug 15, 2022

Hi @serbynskyi! 👋
Thank you for joining. Please accept team invitation 👉 here 👈 and add your comment one more time.

@serbynskyi
Copy link
Contributor

@magento I am working on this

@Kiraberos
Copy link
Contributor

@magento add to contributors team

@m2-assistant
Copy link

m2-assistant bot commented Aug 16, 2022

Hi @Kiraberos! 👋
Thank you for joining. Please accept team invitation 👉 here 👈 and add your comment one more time.

@GrzegorzWalewski
Copy link

@magento add to contributors team

@m2-assistant
Copy link

m2-assistant bot commented Aug 25, 2022

Hi @GrzegorzWalewski! 👋
Thank you for joining. Please accept team invitation 👉 here 👈 and add your comment one more time.

@GrzegorzWalewski
Copy link

@magento I am working on this

@GrzegorzWalewski
Copy link

GrzegorzWalewski commented Aug 25, 2022

I don't have time right now to fix it on Magento's repo, but here is a patch I came with which fix this issue:
File path: vendor/magento/framework/Data/Collection/AbstractDb.php

--- /dev/null
+++ ../Data/Collection/AbstractDb.php
@@ -393,7 +393,7 @@
                 $conditions[] = $this->_translateCondition($value, isset($condition[$key]) ? $condition[$key] : null);
             }
 
-            $resultCondition = '(' . implode(') ' . \Magento\Framework\DB\Select::SQL_OR . ' (', $conditions) . ')';
+            $resultCondition = '(' . implode(') ' . \Magento\Framework\DB\Select::SQL_AND . ' (', $conditions) . ')';
         } else {
             $resultCondition = $this->_translateCondition($field, $condition);
         }

The only thing that has to be changed is SQL_OR to SQL_AND – if we use more filters, we want the data we receive
(e.g., products, orders) to meet all our requirements, not just one of them. E.g., we want orders from within dates – not before max date and after min date.

serbynskyi added a commit to serbynskyi/magento2 that referenced this issue Aug 26, 2022
@m2-community-project m2-community-project bot moved this from Dev In Progress to Pull Request In Progress in High Priority Backlog Aug 26, 2022
@github-jira-sync-bot github-jira-sync-bot added Progress: ready for grooming Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: ready for grooming labels Sep 7, 2022
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Done in High Priority Backlog Sep 29, 2022
@m2-community-project m2-community-project bot added Progress: done and removed Progress: PR Created Indicates that Pull Request has been created to fix issue Progress: PR in progress labels Sep 29, 2022
@engcom-Hotel
Copy link
Contributor

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket AC-1805 by the internal team
Related commits: https://github.com/magento/magento2/search?q=AC-1805&type=commits

Based on the Jira ticket, the target version is 2.4.6.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: APIs Component: GraphQL GraphQL Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Project: GraphQL Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Development

Successfully merging a pull request may close this issue.