Use an around plugin to silence a function in Magento
Learn how to use a Magento 2 around plugin to disable an observer execute function without affecting the module.
Lesson Content
Letβs take things a step further and assume that we want to prevent this execute() function in the LogPostDetailView observer from running at all, but we still want the rest of the module to function. You can do this with an around plugin.
Generally, you donβt want to use around plugins. They increase the size of the call stack and usually make debugging very difficult. A valid use, though, is to prevent a function from executing.
Create a new plugin named PreventPostDetailLogger:
<?php
declare(strict...
Join the discussion!
Comments
Want to comment on this lesson?
Enroll in this course to leave comments.