2020 is quite an unusual year in many aspects and this reflects in all the spheres of our life. Holiday season 2020 is not an exception and will be more challenging for e-commerce than any other before. Knowing that first hand, hearing this from our customers, we sat down with Nexcess, a hosting partner, to put together tips on what we already do best — helping our customer’s stores perform at the highest level possible despite the circumstances.
Before COVID-19 cut the possibility of public gatherings, we had plenty of offline hackathons or contribution days in the Magento community world. An essential part of a working toolkit at such events is, obviously, a laptop (there were gurus that wrote the code even on tablets but that’s a different story). And at every table, along with 10 developers with serious faces, you saw at least 7 MacBooks and 3 [something else] with Ubuntu on board. If you are lucky enough, you may meet a dev who uses a Windows-based laptop as a working station but it’s rather a rare exception to the rule.
The growing unpopularity of Windows-based laptops among web-developers in the past has its roots. There was a period when Windows could not provide a toolkit powerful enough for productive web application development. Many developers, who made the switch from Windows to OSX or Linux, never looked back. But during the last few years, the situation with the Windows platform has changed dramatically. Microsoft took the direction of improving the development tools they own (VS Code, WSL) and acquiring new ones (GitHub). We would like to share our recent experience in building Magento 2 local development environment using Docker and WSL 2.
Magento events and observers are a good old way of extending Magento. They came from Magento 1, but an approach is well-known beyond the Magento community and platform. It follows an observer design pattern and has different implementation and variations in different frameworks. This article covers how Event Framework was implemented in Magento and how it’s suggested to be using by Magento Development Team.
Starting from Magento 2.3 the Registry class that is (or was) used by a lot of developers and extension vendors is declared to be deprecated. In class comments it’s told to use service classes or data providers, but no examples provided. This article aims to show how you can get needed data using best practices and service classes.
You already know how to create a simple CLI script. The CLI scripts are initialized with a different area – basically, with a separate CLI area\aplication, which lacks the standard frontend\admin localizations functionality. We faced that when developing a script for sending order emails via CLI – the emails were missing translations of the origin of the order. Let’s try to figure out “why?” and “how to fix?”.
It is always good when you can test your features fast. But sometimes it’s literally hard and takes a lot of time to test something in Magento. When you make one little change in code and want to test it, it can take much more time to test it rather than make the change itself. Nevertheless it’s a common situation taking into account the complexity of Magento.
Every unit test ninja faces troubles whenever he wants to test some real class functionality. Have you ever invoked toHtml() method of some block or beforeLoad() method of any collection? If you want to do it, you will need to mock a lot of classes that depend on other classes and so on. You would need to mock all of them, which would take a lot of time and effort. In a long run, you may blow up deadlines and it would really suck. Yes, you can try to change your testing strategy to avoid invoking such methods. But what if you still need to test them? I’m going to show you how I handled this problem.
Before running your store in production mode it’s very important to check as many Magento 2 performance aspects as possible, since even a minor performance issue might cost time and money in the future. Formally, a web application’s performance can be classified using two parts: frontend performance and backend performance.
During our work with Magento 2 Rich Snippets module we’ve noticed that the product list page has numerous errors if switched to the 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 blog post describes a configurable fix for the 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.
When we talk about checking bottlenecks in Magento backend implementations we often mention the built in profiler that allows to see loading time of particular backend functional elements. There are two general factors of such bottlenecks: heavy (or repetitive) database calls or slow PHP operations such as loops and similar cases.