What risk does this pose, and how can it be mitigated?

In a code review of a merchant’s site you have discovered that there are multiple observers for the checkout_submit_all_after event. After closer inspection, you notice one of these observers is relying on the others being executed before it is called.
What risk does this pose, and how can it be mitigated?
A. There is no risk posed as long as each event observer specifies a correct sortOrder. Nothing needs to be changed.
B. Event observers are fired in alphabetical order of the observer name. There is no risk here.
C. Magento only supports one observer per event. These observers will need to be combined into a single point of customization.
D. Order of listener execution cannot be guaranteed, resulting in a fragile implementation. This code should be re-worked using plugins

Download Printable PDF. VALID exam to help you PASS.

8 thoughts on “What risk does this pose, and how can it be mitigated?

  1. Answer: should be D

    Regarding sort order – Magento not allowed sort orders in observer
    Regarding the alphabetical order of the observer name – If there are mutiple observers for the event then the Magento 2 behavior becomes unpredictable because we can not set the observer’s ordering.
    Regarding the answer C – We have used multiple modules in the project and every module define its own feature so this is wrong

    1
    1
  2. After a few reviews of this question i now agree that D should be the right answer, as this specifies that. code review is taking place and if you read into the question although the Event observers execute in Alpha order. Theres no guarantee that all observers are named in the correct way to order them correctly. So D would be best answer

  3. I think B is indeed correct because you can guarantee the order by depending obervers on others. Everything else is fired alphabetically, I do agree you should rework using plugins but the statement that the order cannot be guaranteed is not true. I think D is correct, but B is “more” correct

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.