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

[32279][GraphQL] Fixed issue with tier price #32353

Merged

Conversation

Usik2203
Copy link
Contributor

@Usik2203 Usik2203 commented Mar 3, 2021

Description (*)

This PR fixes issue #32279
(Confirmed issue case #32279 (comment))

Preconditions

Tier price was added for product with name
banana and banana-1

BEFORE:
Screenshot 2021-03-03 at 13 36 48
AFTER:
Screenshot 2021-03-03 at 13 38 58

Fixed Issues (if relevant)

  1. Fixes Graphql price tiers returning data from previous item in foreach #32279

@m2-assistant
Copy link

m2-assistant bot commented Mar 3, 2021

Hi @Usik2203. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

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

⚠️ According to the Magento Contribution requirements, all Pull Requests 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 Pull Requests 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

@m2-community-project m2-community-project bot added Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Severity: S1 Affects critical data or functionality and forces users to employ a workaround. labels Mar 3, 2021
@magento-engcom-team magento-engcom-team added Component: CatalogCustomerGraphQl Release Line: 2.4 Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner labels Mar 3, 2021
@Usik2203 Usik2203 changed the title [32279] Fixed issue with tier price issue [32279][GraphQL] Fixed issue with tier price issue Mar 3, 2021
@m2-community-project m2-community-project bot removed this from Pending Review in GraphQL Pull Requests Dashboard Mar 3, 2021
@Usik2203
Copy link
Contributor Author

Usik2203 commented Mar 3, 2021

@magento run all tests

@eduard13 eduard13 self-assigned this Mar 3, 2021
@eduard13 eduard13 self-requested a review March 3, 2021 13:37
@m2-community-project m2-community-project bot moved this from Pending Review to Review in Progress in High Priority Pull Requests Dashboard Mar 3, 2021
Copy link
Contributor

@eduard13 eduard13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Usik2203, could you please review the comments below?

Thank you.

@@ -152,7 +155,7 @@ private function formatAndFilterTierPrices(
array $tierPrices,
string $currencyCode
): array {

$this->resetFormatAndFilterTierPrices();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply cleaning the formatAndFilterTierPrices? Any concerns about that?

Suggested change
$this->resetFormatAndFilterTierPrices();
$this->formatAndFilterTierPrices = [];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eduard13
Unfortunately this approach isn't working in this case
We are losing some data
We will get tier price only for first item in this case
Example:
Screenshot 2021-03-03 at 15 51 11
But actually banana-1 product has tier price

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, I think you do the same in resetFormatAndFilterTierPrices below, cleaning the formatAndFilterTierPrices. Am I wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eduard13
Yes you are right. It was my mistake 🤦
Fixed this one
Thanks!

/**
* @magentoApiDataFixture Magento/Catalog/_files/three_simple_products_with_tier_price.php
*/
public function testGetCorrectDisplaingTierPriceForProducts()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most probably we'll have to improve the test coverage, by having at least 1 product without tierPrices, in order to make sure it doesn't return anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**DONE **
Added one product without tier price.

@m2-community-project m2-community-project bot moved this from Review in Progress to Changes Requested in High Priority Pull Requests Dashboard Mar 3, 2021
@m2-community-project m2-community-project bot moved this from Changes Requested to Review in Progress in High Priority Pull Requests Dashboard Mar 3, 2021
@Usik2203 Usik2203 force-pushed the 32279-issue-with-tier-price branch from 045dd0b to 457b0ea Compare March 3, 2021 16:30
@SirCoolness
Copy link

@magento give me test instance

@Usik2203
Copy link
Contributor Author

@magento run all tests

@eduard13
Copy link
Contributor

@magento run Functional Tests EE

@eduard13 eduard13 added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Mar 30, 2021
@magento-engcom-team
Copy link
Contributor

Hi @eduard13, thank you for the review.
ENGCOM-8985 has been created to process this Pull Request

@dmitriyprime
Copy link
Contributor

✔️ QA passed

Before
{
"data": {
"products": {
"items": [
{
"id": 2,
"price_tiers": [
{
"quantity": 3,
"final_price": {
"value": 140
}
},
{
"quantity": 5,
"final_price": {
"value": 130
}
}
]
},
{
"id": 1,
"price_tiers": [
{
"quantity": 5,
"final_price": {
"value": 130
}
},
{
"quantity": 5,
"final_price": {
"value": 90
}
},
{
"quantity": 10,
"final_price": {
"value": 80
}
}
]
},
{
"id": 6,
"price_tiers": [
{
"quantity": 5,
"final_price": {
"value": 130
}
},
{
"quantity": 5,
"final_price": {
"value": 90
}
},
{
"quantity": 10,
"final_price": {
"value": 80
}
}
]
},
{
"id": 5,
"price_tiers": [
{
"quantity": 5,
"final_price": {
"value": 130
}
},
{
"quantity": 5,
"final_price": {
"value": 90
}
},
{
"quantity": 10,
"final_price": {
"value": 80
}
}
]
},
{
"id": 4,
"price_tiers": [
{
"quantity": 5,
"final_price": {
"value": 130
}
},
{
"quantity": 5,
"final_price": {
"value": 90
}
},
{
"quantity": 10,
"final_price": {
"value": 80
}
}
]
},
{
"id": 3,
"price_tiers": [
{
"quantity": 5,
"final_price": {
"value": 130
}
},
{
"quantity": 5,
"final_price": {
"value": 90
}
},
{
"quantity": 10,
"final_price": {
"value": 80
}
}
]
}
]
}
}
}

✔️ After:
{
"data": {
"products": {
"items": [
{
"id": 2,
"price_tiers": [
{
"quantity": 3,
"final_price": {
"value": 140
}
},
{
"quantity": 5,
"final_price": {
"value": 130
}
}
]
},
{
"id": 1,
"price_tiers": [
{
"quantity": 5,
"final_price": {
"value": 90
}
},
{
"quantity": 10,
"final_price": {
"value": 80
}
}
]
},
{
"id": 6,
"price_tiers": []
},
{
"id": 5,
"price_tiers": []
},
{
"id": 4,
"price_tiers": []
},
{
"id": 3,
"price_tiers": []
}
]
}
}
}

@dmitriyprime dmitriyprime added the QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope label Apr 23, 2021
@m2-community-project m2-community-project bot moved this from Testing in Progress to Ready for Testing in High Priority Pull Requests Dashboard Apr 23, 2021
@dmitriyprime dmitriyprime moved this from Ready for Testing to Merge in Progress in High Priority Pull Requests Dashboard Apr 23, 2021
@magento-engcom-team magento-engcom-team merged commit 8c322c9 into magento:2.4-develop Apr 26, 2021
@m2-assistant
Copy link

m2-assistant bot commented Apr 26, 2021

Hi @Usik2203, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Component: CatalogCustomerGraphQl Event: Adobe Summit Hackathon Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Graphql price tiers returning data from previous item in foreach
5 participants