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.

Working with custom configuration files in Magento 2

As you may know, initially Magento keeps all configuration values in XML files. XML structure allows dividing all configuration values into separate sections, subsections, etc. In that way, every configuration value has its own path in the configuration three (called XPath). We usually work with Magento built-in configuration files, however, there are some situations when we need to have our own configuration file alongside with the standard files.

Configure Code Sniffer for PHPStorm and Magento 2

For a good and maintainable application, high-quality product code is essential. The code quality usually depends on the developer’s professionalism. But among the thousands of lines of code, something might be missed. Fortunately, there are several small yet useful utilities that can automate some routines and help you check the code using different rules for different coding standards. In PHP development, there are two popular utilities for code validation: Code Sniffer and Mess Detector.

Magento 2 request flow overview

It’s interesting to know how Magento 2 works “under the hood” not only for developers but for all the people, who work with the platform. Not everyone has a possibility to dig in the code deeply enough in order to check the details. In this post we will put Magento 2 request flow in layman’s terms.

Error page customization in Magento 2

So, if you encounter a Magento 2 internal server error, it won’t appear as a white page with black textHave you ever seen a page with “There has been an error processing your request” when using Magento 1 or Magento 2? If no, you are lucky. This page is usually displayed when an issue appears in a system execution flow. Magento processes such issues by creating a separate report file in the var/report directory and by showing the error page with the details. You can also see a similar page “Service Temporarily Unavailable” when the maintenance mode has been enabled. Did you know that you can easily customize these error pages?

Magento 2 Product list aggregate rating fix

During our work with the Magento 2 Rich Snippets module, we noticed numerous errors on the product list page when switched to list mode. The errors were generated by the standard Magento 2 Luma theme, when attempting to aggregate rating markup rendering for each product in the product list. This article outlines a configurable solution to address this issue. We will have an opportunity to disable this fix for any custom theme which doesn’t have this error or in case the next Magento 2 version has a fix for this included.

Setting up Magento 2 cron jobs

Scheduled background processes are important in any large system. Clean ups and keeping cache and indexes up to date allow to keep your system healthy, while some processes are simply need to be stretched in time in order to avoid high system load, memory leaks or certain services overload (massive emails sending). Setting up a cron job for such processes and for the processes that should be repeated from time to time is always a good idea. In this blog post we will describe how to set a certain part of code as a cron job in Magento 2.