Skip to content

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

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

Open
wants to merge 15 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

fredden
Copy link
Member

@fredden fredden commented Jun 13, 2020

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 (*)

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

Resolved issues:

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

This is in order to allow additions to the return value of the private method
getCategoryAsArray() via a plugin on
Magento\Catalog\Observer\MenuCategoryData::getMenuCategoryData()
@m2-assistant
Copy link

m2-assistant bot commented Jun 13, 2020

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

❗ 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

ℹ️ 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.

Copy link
Contributor

@lbajsarowicz lbajsarowicz left a comment

Choose a reason for hiding this comment

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

Injection of Observer to Plugin is not the best idea at all.
If you need the logic reusable across these two - just create separate class that provides Interface you need.

@fredden
Copy link
Member Author

fredden commented Jun 15, 2020

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

@fredden fredden requested a review from lbajsarowicz June 15, 2020 08:08
@sidolov sidolov added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Aug 18, 2020
@sidolov
Copy link
Contributor

sidolov commented Aug 18, 2020

@magento create issue

@magento-automated-testing
Copy link

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-automated-testing
Copy link

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-automated-testing
Copy link

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.

1 similar comment
@magento-automated-testing
Copy link

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-automated-testing
Copy link

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-automated-testing
Copy link

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.

@fredden
Copy link
Member Author

fredden commented Feb 5, 2024

@magento run all tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Partner: Fisheye partners-contribution Pull Request is created by Magento Partner Priority: P3 May be fixed according to the position in the backlog. Progress: pending review Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Use MenuCategoryData to generate array in TopMenu plugin to allow extension via plugins
4 participants