Use MenuCategoryData to generate array in TopMenu plugin to allow extension via plugins
Description
Following discussion on Magento Community Engineering Slack instance, it has become clear that the private method Magento\Catalog\Plugin\Block\Topmenu::getCategoryAsArray() should be abstracted to allow extension via plugin (as inheritance (via preference) is to be discouraged). It appears that an existing class provides most of the functionality required. This pull request changes getCategoryAsArray() to use this existing external class (with public method) to allow this data to be augmented via plugin on the latter.
Related Pull Requests
None known
Fixed Issues
None known
Manual testing scenarios
See also discussion on Slack (link above).
- Attempt to add an item to output of
getCategoryAsArray()from external code (third party extension)
Questions or comments
I have not yet adjusted any tests, however this should not result in any change in functionality.
Contribution checklist (*)
- [x] Pull request has a meaningful description of its purpose
- [x] All commits are accompanied by meaningful commit messages
- [x] All new or changed code is covered with unit/integration tests (if applicable)
- [x] All automated tests passed successfully (all builds are green)
Resolved issues:
- [x] resolves magento/magento2#29664: Use MenuCategoryData to generate array in TopMenu plugin to allow extension via plugins
Hi @fredden. 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.4-develop instance- deploy vanilla Magento instance
:exclamation: 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:
-
Database Compare -
Functional Tests CE -
Functional Tests EE, -
Functional Tests B2B -
Integration Tests -
Magento Health Index -
Sample Data Tests CE -
Sample Data Tests EE -
Sample Data Tests B2B -
Static Tests -
Unit Tests -
WebAPI Tests
You can find more information about the builds here
:information_source: 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.
MenuCategoryData isn't an observer, but a model in the wrong namespace. I've now moved it to 'Model'.
@magento create issue
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
@magento run all tests
@magento run all tests
@fredden Are you willing to proceed with pushing this PR?
@lbajsarowicz I have merged in the latest changes from the destination branch. Was there something else that you think needs to be done here?
@magento run all tests
@magento run all tests
@magento run all tests