-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Added a dedicated modifier pool for categories #30119
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
base: 2.4-develop
Are you sure you want to change the base?
Conversation
Hi @bgorski. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
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. 🕙 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 |
@magento run all tests |
@magento run Functional Tests B2B |
Hi @bgorski. Thank you for your improvement. From my point of view, that's a good idea since I met a similar problem with the virtual type overriding for the pull. Could we create a simple integration test that ensures that the pool of category data provider is not null after the change introduced in this PR? |
@magento create issue |
The pool wouldn't be null before this PR is introduced, because the parent constructor assigns a generic |
…ory\DataProvider with null as the modifier pool
@magento run all tests |
I went ahead and did exactly what I mentioned in my previous comment. The integration test that will test the correct instantiation of the data provider is |
@magento run all tests |
@magento run all tests |
Actually I reverted the change above. It would be a major change as the data provider is marked with |
@magento run all tests |
@magento run Functional Tests B2B, Functional Tests CE |
Hi @bgorski. Thank you for providing the extended information on that matter. Let's wait with the complex test and check for approval from architects for this change. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this PR with "Not test required option". I see no easy way to cover this case with an automated test without developing a separate modifier
Hi @rogyar, thank you for the review. |
Hello @bgorski Thanks for the collaboration & contribution! ✔️ QA Passed Install fresh Magento 2.4-develop
Category edit page is working as expected with the changes from PR. Builds are failed. Hence, moving this PR to Extended Testing. Thanks |
@magento run all tests |
@magento run Unit Tests, Magento Health Index, Functional Tests B2B |
@magento run all tests |
@magento run Functional Tests EE, Functional Tests B2B |
The Functional B2B test failures are different in recent 2 successive builds. They neither part of PR nor failing because of the PR changes, hence moving it to Merge in Progress. Run 1: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/30119/6e2c6d60cd098595f84235f49bb79ba1/Functional/allure-report-b2b/index.html#categories/bcf93358aa1b517577cad18e5921ef41/1d255ca3873ee1db/ Run 2: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/30119/a770080f722523271b871a6c7d7f9a3c/Functional/allure-report-b2b/index.html#categories/6cd9617c5e67638d802b7c193afd3e9b/9ab34cb795cc76de/ |
Hello @bgorski, Thanks for your contributions! Moving this PR to on hold since it’s a feature request and we need PO approval for it. Once we get approval, we will proceed accordingly. Thanks. |
Hello @bgorski, We have received the go-ahead on this PR from the PO. We are moving it to extended testing for now to analyze the build results with the latest code. Thanks. |
@magento run all tests |
@magento run Functional Tests CE, Functional Tests B2B |
Moving this PR to Extended Testing to resolve the conflicts |
@magento run all tests |
@magento run Functional Tests B2B, Unit Tests |
1 similar comment
@magento run Functional Tests B2B, Unit Tests |
@magento run all tests |
Description (*)
This PR greatly decreases chances for conflicts if your application has more than one custom or 3rd party module extending category edit form using modifiers.
The problem:
As we know, ui component forms can be extended either in xml files or using modifiers written in PHP and injected via modifier pools to their corresponding form.
This is easy for products, the
etc/adminhtml/di.xml
file in the Magento_Catalog module defines aMagento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool
virtual type with some modifiers already there and injects it as thepool
argument forMagento\Catalog\Ui\DataProvider\Product\Form\ProductDataProvider
. If you want to add your own argument, you simply target that virtual class in your own di.xml and add a new item to the modifiers array.However, in case of categories it's not that straightforward. Although the overall logic is the same, categories don't have any virtual type for the pool defined. So they get
null
as thepool
argument and end up with the genericMagento\Ui\DataProvider\Modifier\Pool
as the pool, which is added in the parent constructor of the data provider. Needless to say, you can't add your own modifiers that are related to category form to that generic pool.This means that if you want to add modifiers to category form, you need to create your own virtualType for the pool, add your modifier to it and inject it as the
pool
argument for the data provider for the category form. Which works if you happen to have only one module doing that, but if you have more than one, a conflict is guaranteed (they last one to load wins and overwrites thepool
argument with its own pool).A solution to that is adding a new virtualType for that pool and injecting it as the
pool
argument directly in the Magento_Core. Although that pool doesn't contain any actual modifiers by default, it serves as a point to which custom/3rd party modules can hook to and add their own modifiers without conflicts.This is also a backwards-compatible solution, because if you happen to already have some module adding its own pool to the category form, that pool will overwrite the empty one added in this PR (assuming you have a correct sequence in your module.xml, with Magento_Catalog added there).
Manual testing scenarios (*)
Contribution checklist (*)
Resolved issues: