QuestionQ6

Architecture

A developer has identified a bug within a private method of a third-party module class.

How can the developer override that method?

  • A Create a custom class with corrected logic, and define the class as preference in the preferences.xml.
  • B Create a custom class with the corrected logic, and define the class as a preference for original one in the di.xml.
  • C Create a plugin, implement correct logic in the 'after' method, and then define the plugin in the di.xml.
Explanation

Adobe Commerce class preferences are declared in di.xml and cause the object manager to instantiate the custom replacement class. A private method cannot technically be overridden directly; the replacement class must instead alter the public or protected caller so it uses the corrected functionality.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!