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

Fix #21725 - Render price on category list with correct precision for current locale #31661

Open
wants to merge 4 commits into
base: 2.5-develop
Choose a base branch
from

Conversation

Bartlomiejsz
Copy link
Contributor

@Bartlomiejsz Bartlomiejsz commented Jan 15, 2021

Description (*)

I recreated #21829 here, which got accidentally closed, when I tried to re-create changes on top of 2.5-develop. I adjusted changes to latest comment from @sivaschenko - while I will work on fixing test that might still fail, would be great if you could verify if such approach is what you meant.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Price Precision wrong on product listing pages #21725

Manual testing scenarios (*)

  1. Default locale set should be for Oman (ar_OM it's not by default available in Magento, need to be added in \Magento\Framework\Locale\Config but didn't check all locales to verify where it also occurs), Oman Rial (OMR) selected as currency
  2. Visit product listing page - see that the products have prices with precision 3.
  3. Visit product details page - see that the products have prices with precision 3.
  4. Visit all other places on frontend where price is displayed - precision should be same there.

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Jan 15, 2021

Hi @Bartlomiejsz. Thank you for your contribution
Here is 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.5-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: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S1 Affects critical data or functionality and forces users to employ a workaround. labels Jan 15, 2021
@magento-engcom-team magento-engcom-team added Partner: Fast White Cat partners-contribution Pull Request is created by Magento Partner labels Jan 15, 2021
@Bartlomiejsz
Copy link
Contributor Author

@magento run all tests

@ihor-sviziev ihor-sviziev self-assigned this Jan 16, 2021
@sivaschenko sivaschenko added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Jan 17, 2021
@@ -387,7 +394,8 @@ public function __construct(
OrderItemRepositoryInterface $itemRepository = null,
SearchCriteriaBuilder $searchCriteriaBuilder = null,
ScopeConfigInterface $scopeConfig = null,
RegionFactory $regionFactory = null
RegionFactory $regionFactory = null,
?PricePrecisionInterface $pricePrecision = null
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it makes sense to allow to pass null as argument explicitly

Suggested change
?PricePrecisionInterface $pricePrecision = null
PricePrecisionInterface $pricePrecision = null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure @sivaschenko, I thought that should be done according to Adding a constructor parameter point from https://devdocs.magento.com/contributor-guide/backward-compatible-development/, I can change that

Copy link
Member

Choose a reason for hiding this comment

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

Hm, this change was introduced in magento/devdocs#6033

I don't think that is correct.

@sidolov @gabrieldagama what do you think guys?

* @deprecated precision should be retrieved from current locale
* @see \Magento\Framework\Pricing\Price\PricePrecisionInterface::getPrecision
*/
const DEFAULT_PRECISION = null;
Copy link
Member

Choose a reason for hiding this comment

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

I'd keep the constant value unchanged, it's enough to deprecate the constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sivaschenko making this fix without changing this constant value would require many more code changes. This constant is used in many places in whole codebase (i.e.

), because precision is third parameter of the format method.

And I changed this parameter to be null as default, so my idea was to:

  • change const value to also null - so every place that uses it, just to pass it as default value to the methods I changed, will also work as expected
  • deprecate const - so make a note across codebase that every it occurrence should be replaced with simply null, but maybe in some next PR, to not make it over complicated.

Copy link
Member

Choose a reason for hiding this comment

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

I think eliminating this constant from the calls is a safer and more backward compatible change than changing the constant value, considering that we don't know how this constant might be currently used in extensions and customizations.

@sivaschenko
Copy link
Member

@Bartlomiejsz thanks for the updates!

I've moved the pull request to To Approve column and launched a formal approval process for this change.

Internal ticket: https://jira.corp.magento.com/browse/MC-40452

@Bartlomiejsz
Copy link
Contributor Author

@magento run all tests

@Bartlomiejsz
Copy link
Contributor Author

@magento run Unit Tests

@Bartlomiejsz
Copy link
Contributor Author

@sivaschenko that seems to be ready for review :)

@Bartlomiejsz
Copy link
Contributor Author

@magento run Functional Tests B2B

@sivaschenko
Copy link
Member

This change was not approved for the 2.4 release line. Internal approval request MC-40452.

There is no active delivery of pull request to 2.5 release line currently, so the PR processing might be delayed.

@ihor-sviziev ihor-sviziev added this to the 2.5 milestone Apr 29, 2021
@ihor-sviziev
Copy link
Contributor

Added this PR to 2.5 milestone

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 Partner: Fast White Cat partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: review 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.

4 participants