Video Lesson: Listen to an event with an observer in Magento

Listen to an event with an observer in Magento

This is premium content

Only available to enrolled or University students.
Join today to unlock all lessons in this course.

Listen to an event with an observer in Magento

Learn how to listen to Magento events with observers and log blog post detail view request data.

Lesson Content

Let’s say we wanted to listen for this macademy_blog_post_detail_view event and carry out an action on it, such as outputting the page response to a log file. We can do this with an observer.

Observers are the other half of an event, and allow you to carry out an action that requires no response by the code that has dispatched an event. Observers work from the relationship between two files: an XML file and a related PHP class that is the observer. The XML defines which event you’d like to listen to, and it references the PHP class that is observing this event:

![](https://codex-assets...

Premium content

Enroll to unlock the full content and all course materials.

Maggie

Hey, I'm Maggie! πŸ‘‹

Ask me anything.

Want to chat with Maggie?

Enroll in this course for AI tutor access.

Comments

Join the discussion!

Comments

Want to comment on this lesson?

Enroll in this course to leave comments.