Ever struggled how to add programmatically a custom layout handle to a product page and what’s the best way to do it? Use the power of Magento 2 plugins (also called interceptors) added into the right place and you’re done!
In order to add a custom layout handle to category page, a (basic) Magento 2 module with these additional files and their content is needed:
1. The events.xml
file to “subscribe” to the event and say which observer should be fired ↵
2. An observer that adds a new layout handle to the page ↵
3. A layout file that adds needed changes to the page ↵