magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Use MenuCategoryData to generate array in TopMenu plugin to allow extension via plugins

Open fredden opened this issue 5 years ago • 15 comments

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

  1. 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:

  1. [x] resolves magento/magento2#29664: Use MenuCategoryData to generate array in TopMenu plugin to allow extension via plugins

fredden avatar Jun 13 '20 19:06 fredden

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:

  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

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.

m2-assistant[bot] avatar Jun 13 '20 19:06 m2-assistant[bot]

MenuCategoryData isn't an observer, but a model in the wrong namespace. I've now moved it to 'Model'.

fredden avatar Jun 15 '20 08:06 fredden

@magento create issue

sidolov avatar Aug 18 '20 19:08 sidolov

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

fredden avatar Feb 05 '24 22:02 fredden

@magento run all tests

fredden avatar Aug 24 '25 17:08 fredden

@fredden Are you willing to proceed with pushing this PR?

lbajsarowicz avatar Nov 20 '25 13:11 lbajsarowicz

@lbajsarowicz I have merged in the latest changes from the destination branch. Was there something else that you think needs to be done here?

fredden avatar Nov 21 '25 18:11 fredden

@magento run all tests

fredden avatar Nov 21 '25 18:11 fredden

@magento run all tests

engcom-Hotel avatar Dec 10 '25 05:12 engcom-Hotel

@magento run all tests

fredden avatar Dec 16 '25 23:12 fredden