Use TIMESTAMPDIFF to identify long running cronjobs in Magento2

magento2_teaser_patch

Improving performance in cron jobs can be very time consuming. Even just figuring out where to start can take hours.

I came up with an idea that really helped me to locate potential performance killer just by checking the execution time by using TIMESTAMPDIFF. For example:

Output example:

The runtime can be a sign of high memory or CPU usage, therefore, you should probably look at those cron jobs first.

Magento 2 – How to fix ” The order confirmation email is not sent “

Magento2 Teaser

This morning I was working on an email issue ( multi-store ) where customers were able to purchase but didn’t receive the order confirmation email.

As always, I had a look at what has been deployed recently and checked pretty much all logs on the production environment. Unfortunately, I couldn’t find anything.

I started looking at database changes, especially the core_config_data table, and noticed that the template for the order confirmation was defined twice. This was kind of weird because those email settings were set to ” Use System Value “.

I ended up deleting the IDs 4293, 4296, 4299 which has fixed the issue immediately. I still don’t know why those values were set twice, but I hope this will help someone…sometime.

October CMS – Widget OC Media Manager

October CMS Logo

If you work with the form elements fileupload or mediafinder in combination with user admin roles ( Settings > Administrators ) you may end up with the following error while saving a model.

In order to fix that, you must review the permissions of your admin user account for Upload and manage media contents – images, videos, sounds, documents. and select Allow or Inherit, depending on how you setup your roles.

October CMS - Admin User Roles Media

After saving the permissions, you should be able to upload or select an image and save the model.

Notice: Use of undefined constant T_CURLY_OPEN – assumed ‘T_CURLY_OPEN’ in /var/www/src/setup/src/ Magento/Setup/Module/ Di/Code/Reader/FileClassScanner.php on line 72

Today I finally had some time to cleaned up my Dockerfile for Magento 2. I am using Alpine Linux for most of my Magento 2 projects which usually includes NGINX, PHP-FPM and MariaDB.

While testing my updated Dockerfile I came across the following PHP notice which prevented the deployment scripts from finishing the Magento 2 setup.

The problem was simply a missing PHP extension php7.1-tokenizer which has resolved the issue after re-creating the container with –build.

 

PHP message: PHP Fatal error: Interface ‘SessionHandlerInterface’ not found in /var/www/src/vendor/ laravel/framework/src/Illuminate/Session/FileSessionHandler.php on line 10

Today I successfully installed my first October CMS project locally via composer / command line. The installation was pretty straightforward and worked surprisingly well on my Alpine Linux docker container which includes NGINXPHP-FPM and MariaDB.

However, when I tried to open the front-end I got the following error.

After a quick research I found the solution on Stackoverflow. I basically forgot to install the PHP extension php7-session inside my docker container. I manually installed the missing extension, but also updated my Dockerfile in case I have to rebuild my container.

After that I manually killed all PHP processes to make sure php-fpm loads the new extension with the next page reload.

 

The use of function filectime() / filemtime() is discouraged in Magento2

How to fix ... in Magento

The problem I had today was located in a helper ( [Namespace]\[Module]\Helper\FileSystem ) which I have created for some basic filesystem operations. The below message was the result of Magento’s EQP which I use before I commit any code.

The warning message basically means, I should find another way to get the creation and modification time of a file because of Magento’s coding standards. I have done that a couple of times already and would like to share my solution this time. First you have to pass \Magento\Framework\Filesystem\Driver\File in your existing constructor or create a new one.

Once you have re-compiled your code, you have access to the file stats as follows.

Beside ctime and mtime the array $fileData should have other file information like size, atime, uid and gid.

UI Components and searchResultToOutput in Magento2

Today I had to fix the following issue in a custom module. The error appeared on the UI Component list view.

I found the reason of the problem in the di.xml file. All what was missing was the following virtualType node. After adding this and re-compiling the code, the list view was fixed.

UI Component Listing And Not registered handle in Magento2

Today I created a new listing for a custom module, but unfortunately all what I got was the error message below.

After digging around for few minutes I noticed the above handler was actually missing in the di.xml file. I simply added the following collections argument and re-compiled the code.

All good!

Missing required argument $name of Xtento\ProductExport\Logger\Logger.

If you are using Xtento in combination with an automated product importer, you may have seen the following error before.

The error message appears right after saving a product. The reason is that, at least one of your products in Products > Catalog has no Name. To fix this, you can update the name manually via MySQL queries or simply delete the products and import again correctly.

Category “Default Category/abc/def/” has not been created. URL key for specified store already exists in Magento2

A new day, a new problem. While importing new products in Magento 2.1.2 via System > Data Transfer > Import something was causing the following error message.

The CSV file was 100% correct, which was making it difficult to figure out why it is causing the error. I ran few more test imports and noticed that the main category actually had an empty space at the end, which I believe was causing the whole problem.

Magento2 Category Name Empty Space

The import ran through without any errors after removing the empty space. However, before I also removed all related URL rewrites as follows. Not sure if this was actually necessary.

After that I rebuilt the re-write table with https://github.com/olegkoval/magento2-regenerate_url_rewrites because for some reason the importer didn’t create the rewrite URLs.

After that everything was working as expected.