The Ultimate Guide to Upgrading your store to Magento 2.4.6

How to upgrade Magento to 2.4.6? Learn how to make the transition smoothly with this ultimate guide.

Picture for The Ultimate Guide to Upgrading your store to Magento 2.4.6
Picture by Matt Chad
Author photo
Matt Chad
December 27, 2023

Upgrading can be a complex process, but is essential to keep your online store secure.

How to upgrade Magento to 2.4.6?

In this ultimate guide, we'll provide you with all the information and resources you need to make the transition as smooth as possible.

From preparing your store for the upgrade to troubleshooting common issues, we've got you covered.

Why Upgrade to Magento 2.4.6?

This latest version includes important security updates, bug fixes, and performance improvements that will enhance your customers' shopping experience and protect your store from potential threats.

Additionally, upgrading to Magento 2.4.6 ensures that your store is compatible with the latest technologies and integrations, allowing you to stay ahead of the competition.

Before you start upgrading Magento 2

Make sure that you have access to credentials for payment gateways, SMTP and all integrations that your Magento store use. Keep in mind that API keys for the majority of extensions are encrypted. In case of the plugin update that might have changed configuration paths you can't extract them from previous configuration. One of the examples is Klarna Payments module that has been removed from the core Magento 2 and is now a standalone module.

Magento 2.4.6 System Requirements

The latest version of Magento 2, comes with a few significant changes - it no longer supports PHP 7.4, and instead recommends the use of PHP 8.2. This means that if you're running Magento on PHP 7.4, you'll need to upgrade to PHP 8.1 or 8.2 to continue using the latest version of Magento.

PHP 8 doesn't just improve performance, it also introduces some game-changing features like constructor property promotion. This new feature drastically reduces the amount of boilerplate code, resulting in code of higher quality. With less code to write, there are fewer opportunities for bugs to creep in.

Magento 2 can benefit from consturctor property promotion in PHP 8

However, if you're using New Relic monitoring, it's important to note that it does not yet support PHP 8.2. Therefore, you should not update PHP beyond the version 8.1 until New Relic release around Summer 2023.

Update: This New Relic release has introduced the support for PHP 8.2.

Another change in Magento 2.4.6 is its compatibility with MariaDB 10.6 which was not officially available and would break installation on previous Magento versions.

Redis 6 is approaching its end-of-life in 2024, but there's good new: Redis 7.0 is fully compatible with the latest Magento releases and can be used without any issues.

Updates regarding ElasticSearch and OpenSearch will be detailed in the following sections.

New features

The latest version of Magento comes with several exciting changes and improvements that are sure to enhance the store performance.

A new email validation can be enabled whenever an admin user modifies their email. This feature will ask for email verification each time the admin user request change of their email address.

As usual, this release includes previous security patches.

Native SMTP configuration without module

You can configure SMTP for Magento 2.4.6 and above directly from the admin panel. Previously, merchants often resorted to third-party extensions such as Mageplaza SMTP, which also offers customer tracking integrations that may not be necessary for your store.

To configure SMTP in Magento 2.4.6, head to Stores -> Settings -> Configuration -> Advanced -> System. smtp-stores-settings.png

There you can find Mail Sending Settings tab with SMTP mail sending parameters. Magento 2.4.6 SMTP config

Enter your SMTP provider details such as username, password, and hostname. Then save the configuration and flush the Magento 2 cache.

ElasticSearch and Open Search support in Magento 2.4.6

This release brings support to ElasticSearch 8 and OpenSearch 2.5.

Magento Open Source has recently announced that it now includes OpenSearch as its default search engine for both on-premises and cloud deployments. Additionally, OpenSearch is now available as a standalone search engine. This latest release is fully compatible with OpenSearch v2.x and also backward-compatible with OpenSearch v1.

Learn more on how to upgrade ElasticSearch instances from the official documentation.

If you rely on Smile ElasticSuite, there is version 2.11 available for Magento 2.4.6.

Updating Your Extensions and Customizations

One of the most important steps in upgrading to Magento 2.4.6 is ensuring that your extensions and customizations are compatible with the new version.

Before upgrading, check with the developers of your extensions and customizations to see if they have updates available for Magento 2.4.6. If they do not, you may need to find alternative solutions or hire a developer to update them for you.

It's important to note that using outdated extensions and customizations can cause compatibility issues and potentially harm your store's functionality.

Frontend library jQuery upgraded to the version 3

You will have to review theme and template overrides. It is necessary to ensure that all tags such as <div></div> are closed properly, rather than using the self-closing tag <div />.

If tags like <p/> and <span/> are present in an HTML string, the browser will interpret them as <p><span>. Unlike <img />, elements <p> and <span> are not self-closing tags. The browser will only close these tags at the end of the string or when it encounters an element that cannot be contained within the current element. Therefore, if another <p> tag appears, it will close the previously opened <p> tag.

Learn more about migration on the jQuery page in the upgrade guide.

You might come across additional jQuery deprecation errors, such as:

Uncaught TypeError: $.ajax(...).success is not a function

Again, review the changes in your themes files with the current source code for Magento 2 *.html and *.phtml templates.

Zend classes replaced in Magento 2.4.6

The latest versions of Magento have introduced several neat improvements. One of the most notable changes is the replacement of Zend classes with Laminas equivalents.

  • Zend_Validate replaced with laminas-validator
  • Zend_Filter replaced with laminas-filter
  • Zend_Json replaced with laminas-json
  • Zend_HTTP replaced with laminas-http

How to handle these changes?

Zend validators have equivalent classes in the Magento\Framework\Validator namespace.

For example, replace:

Zend_Validate::is($email, 'EmailAddress')

with:

Magento\Framework\Validator\EmailAddress

Same goes with filters, find equivalent classes in the Magento\Framework\Filter namespace. For example:

Zend_Filter_LocalizedToNormalized

is replaced by:

Magento\Framework\Filter\LocalizedToNormalized

JSON serialization and de-serialization should be handled with

Magento\Framework\Serialize\SerializerInterface

Keep in mind that these classes do not provide any static methods and must be injected into your block or view model constructor. If you can't inject this class but third party module relies on Zend_Json, you can replace it with Laminas\Json\Json.

Again, Zend_HTTP is replaced with classes in the Laminas\Http namespace, but according to the Magento 2 best practices, you should stick with Magento Framework classes to process HTTP requests and responses.

A full list of deprecated classes and their replacements is available in the restricted_classes.php file:

vendor/magento/magento-coding-standard/Magento2/Sniffs/Legacy/_files/restricted_classes.php

To minimize the risk of incompatibility with future releases, it's best practice to rely on classes annotated with @api. @api annotated class in Magento 2 example

The latest version of Magento, Magento 2.4.6, has been causing some issues related to the PHP 8 upgrade. One of the major changes is that warnings are now treated as errors, which can be problematic for PHP functions that previously did not complain about nulls being passed instead of primitive PHP types.

This change can lead to unexpected behavior and errors in the code. Additionally, it is important to watch out for errors in analytics modules, as these modules are executed on all pages, including the critical checkout path. Any errors in these modules can cause significant issues for customers trying to complete their purchases.

Another issue to be aware of is that the New Relic agent does not support JIT. This can slightly degrade the performance of cron tasks and indexers. There are few popular modules which were not initially compatible, but recently got updates to work with Magento 2.4.6 and PHP 8.2:

Starting with Magento 2.4.5, Klarna Payments can only be enabled as a standalone module and must be obtained for free from the marketplace.

Performing the Upgrade and Testing Your Site

Once you have ensured that all of your extensions and customizations are compatible with Magento 2.4.6, it's time to perform the upgrade. This process can vary depending on your hosting provider and the size of your store, but Magento provides detailed documentation and support to guide you through the process.

After the upgrade is complete, it's important to thoroughly test your site to ensure that all functionality is working properly. This includes testing checkout, payment processing, and any custom features or integrations. It's also a good idea to test your site's performance and speed to ensure that it is running optimally.

In case you need a help with upgrading your store to Magento 2.4.6, please contact us, and we will safely upgrade your store.

composer require-commerce magento/product-community-edition 2.4.6 --no-update --force-root-updates
composer update

If you're using ElasticSuite, require the compatible version:

composer require "smile/elasticsuite":"~2.11"

Remove the obsolete Mageplaza SMTP module:

composer remove mageplaza/module-smtp

Bonus: apply patched Magento 2 versions

Magento 2.4.6-p1 and 2.4.6-p2 introduced fixes to critical vulnerabilities. Read more in the release notes for p1 and release notes for p2.

Follow the similar composer commands as during the upgrade to apply the Magento 2 patched version:

composer require-commerce magento/product-community-edition 2.4.6-p2 --no-update --force-root-updates
composer update

Conclusion

Upgrading to Magento 2.4.6 offers several significant benefits, including support for the latest PHP versions, updated search engine options, and the removal of outdated Zend_* classes.

The new native SMTP configuration streamlines the process of configuring core e-commerce functionality, reducing the need for external third-party modules.

While dropping support for PHP 7.4 may be a concern for some users, the added support for PHP 8.1 and 8.2 ensures more performant code.

If you are looking to enhance the performance and functionality of your e-commerce platform, upgrading to Magento 2.4.6 is an investment that is definitely worth considering.

Consulting avatar

Do you need assistance with your Magento 2 store?

Share this post

Find more posts by tags
Explore all tags