How to add custom layout handle to category in Magento 2

In order to add a custom layout handle to a category page, a (basic) Magento 2 module with these additional files and 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

Uninstall modules in Magento 2

One of the shortcomings of Magento’s first version was the inability to clean up module data from the database upon its removal. This is a common situation when you uninstall an extension but all the related data remains in the database. You can only get rid of it manually. It is inconvenient especially if the module has created a bunch of new tables, custom attributes, system configurations etc. In such cases, an automatic data removal tool would be highly beneficial.

In Magento 2 there is a great feature, which allows to create an uninstall script for your module. Let’s find out how it works.

Adding an image chooser to a Magento 2 widget

In the previous article we have described how to introduce a new widget in Magento 2. As it was mentioned, each widget field has its own input type. The input type allows determining what graphical interface component will be used to represent this field. Magento 2 has a set of simple input types out of the box such as input field, dropdown etc. Also, it has more complex components: products chooser, rules conditions component, CMS block chooser and others. However, in certain scenarios, you might want to integrate a custom input type, especially if you aim to select images from the media gallery in your widget configuration. In this post we review how to add an image chooser/uploader to your widget.

Adding an image chooser to a Magento 2 widget

Magento 2 has a handy toolkit for static content management on the site that is called Content Management System (CMS). The toolkit consists of three main parts: pages, blocks and widgets. Pages allow us to manage content of an entire page. Blocks provide an ability to edit content of separate page elements. The main difference between blocks and widgets: if you need to change block parameters, you usually have to do it programmatically. Widgets are similar to static blocks, they allow to insert various content into static pages or static blocks. As a rule, widgets have configurable parameters that can be set up when adding it via admin panel.

Filter products by attribute on a Magento CMS page

Ability to create pages with custom content is a great feature provided by Magento. You can easily create a new page for your store and add text, html, images, different widgets there. But sometimes people want to have something non-trivial on their pages. Usually it means that you need to operate some knowledge before you’ll get an appropriate result. In this article we would like to suggest you a simple solution on how to place a products list, prefiltered by some specific attribute, on your CMS page. The example below describes how to create a simple extension for this purpose.