Browsed by
Author: Alexander Dite

Magento Certified Developer Plus Magento 2 Professional Developer Magento 2 Solution Specialist
AJAX loading of related products in Magento 2

AJAX loading of related products in Magento 2

Introduction In some projects the amount of related products can be significant. In my case there were more than 300 related products and upsell products on some product detail pages. The consequence of this was a high time to first byte on product detail pages. In the mentioned project it was about 15 seconds for some of the products. So we searched for a possible optimization. We finally decided to implement asynchronous loading of product recommendations via AJAX. At the…

Read More Read More

How a wrong carrier implementation causes a server outage

How a wrong carrier implementation causes a server outage

Sometimes one wrong line of code can break your site. In the following I will describe a mistake in a Magento 2 custom carrier implementation, which causes a massive overloading of server resources (CPU, RAM, DB processes) and even can cause an outage of your Magento store. The one line of code The following line of code is the reason for the problems, if used in the collectRates() method, or in methods, called from collectRates() in the Carrier class: $quote…

Read More Read More

Sequence of Magento 2 Install / Upgrade / Recurring scripts

Sequence of Magento 2 Install / Upgrade / Recurring scripts

Preamble In one of my last tasks I had to write an upgrade script in which an assignment of a newly created frontend theme to some of the stores should be implemented. The following code-part describes what I did here: /** * */ protected function assignNewThemeToSelectedStores() { $storeIdsForNewTheme = []; foreach ($this->storesCodesWithNewTheme as $storeCode) { $storeIdsForNewTheme[] = $this->storeRepository->get($storeCode)->getId(); } /** @var \Magento\Theme\Model\ResourceModel\Theme\Collection $themes */ $themes = $this->themeCollectionFactory->create()->loadRegisteredThemes(); /** * @var \Magento\Theme\Model\Theme $theme */ foreach ($themes as $theme) { if ($theme->getCode()…

Read More Read More

Cronjob performance optimization: Magento 1 vs. Magento 2

Cronjob performance optimization: Magento 1 vs. Magento 2

Introduction This article is about problems that can occur with Magento cronjobs. The standard way to configure crontab for Magento 1 has it’s limits. The more custom cronjobs  a Magento system has, the more probable the system will face problems considering cronjobs. The most common issues are: Indexer Cronjob (Magento Enterprise malways mode) takes longer than usual so that other cronjobs (mdefault mode) are skipped (not executed) for the time the indexer runs Some of the cronjobs in mdefault scope take a…

Read More Read More

Fixing issues after changing product attribute type from varchar to text

Fixing issues after changing product attribute type from varchar to text

In some cases there is a need to change the backend type of a catalog product attribute from varchar to text. The purpose of this change is to get more than 255 characters space for a string value. In this article I will cover the situation when problems occur after changing the backend type of an attribute. The Problem If the backend type of an attribute is changed, e.g. via install/upgrade script, Magento does not automatically copy and clean up old values….

Read More Read More

Solving a 2006 MySQL error connection timeout in Magento1

Solving a 2006 MySQL error connection timeout in Magento1

In my recent task I was testing a web crawler script which uses Magento database information for the crawling requests. I have encountered the following error: Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[HY000]: General error: 2006 MySQL server has gone away’ in lib/Zend/Db/Statement/Pdo.php:228 The Problem This error occured after around 45 minutes of script runtime. The script was written in a way that it was possible that there is no database interaction for a longer period. In consequence to that…

Read More Read More