Skip to content

Adding a handler to the Magento\Catalog\Helper\Output Class #12371

@quisse

Description

@quisse

I want to add a custom productAttribute handler to the Magento\Catalog\Helper\Output Class. The changelog says it should be done by using a Plugin (because event catalog_helper_output_construct is removed) but as far as I can see, each available method would add the handler multiple times if I don't check if it is already added (which is no clean solution in my opinion). The only proper solution would be adding it after the __construct method with an after plugin method but plugins can't be used with those methods. Does anyone know how this can be done properly?

Preconditions

  1. Magento 2.1.10
  2. PHP 7.0.25

Steps to reproduce

  1. Add a handler by using a plugin method on the Magento\Catalog\Helper\Output Class
  2. The plugin method gets called multiple times
  3. The handler gets added multiple times

Expected result

  1. A proper formatted attribute

Actual result

  1. The proper formatted attribute has been formatted way to much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CatalogFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasehelp wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions