Magento is one of the most popular e-commerce platforms in the world, and its latest version, Magento 2.4.5, offers several improvements and bug fixes over the previous version. If you're running a Magento 2.4.0 store, upgrading to 2.4.5 is a good idea to take advantage of these improvements.
Before you begin the upgrade process, it's essential to back up your files. This includes both your Magento files and your theme files. In case anything goes wrong during the upgrade process, having a backup will allow you to restore your files to their previous state. Ideally this would be attempted within a local development environment, running through the migration/upgrade process numerous times until any errors or issues are resolved.
Before we dive into the specifics of upgrading your theme, it's important to understand the technology stack changes between Magento 2.4.0 and 2.4.5. Magento 2.4.5 includes updates to PHP, Elasticsearch, and the MySQL database. These updates can potentially affect your theme if it uses any custom code or extensions that rely on these technologies. It's important to test your theme thoroughly after upgrading to ensure that everything is working as expected.
To upgrade your theme to Magento 2.4.5, you will need to update your theme's composer.json file to include the new
version of Magento. To do this, open your theme's composer.json file and update the require
section to include
"magento/product-community-edition": "2.4.5"
.
To upgrade the imagery gallery in Magento 2.4.0 to the version found in Magento 2.4.5, you will need to follow these steps:
[magento_root]/vendor/magento/module-catalog/view/frontend/web/js/gallery.js
Copy the entire content of this file and save it to a new file with the same name in your Magento 2.4.0 instance.
[store_root]/app/design/frontend/[your_theme]/Magento_Catalog/web/js/gallery.js
This will replace the existing gallery code with the new code.[magento_root]/vendor/magento/module-catalog/view/frontend/templates/product/view/gallery.phtml
Copy the entire content of this file and save it to a new file with the same name in your Magento 2.4.0 instance.
[magento_root]/app/design/frontend/[your_theme]/Magento_Catalog/templates/product/view/gallery.phtml
This will replace the existing gallery template with the new template.It's essential to test the new gallery thoroughly before making it live to ensure that it works correctly with your website and theme.
A very similar to upgrading the gallery, to upgrade the mini cart in a Magento 2.4.0 theme to support Magento 2.4.5, follow these steps:
[magento_root]/vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html
Copy the entire content of this file and save it to a new file with the same name in your Magento 2.4.0 instance.
[magento_root]/app/design/frontend/[your_theme]/Magento_Checkout/web/template/minicart/content.html
This will replace the existing mini cart code with the new code.[magento_root]/vendor/magento/module-checkout/view/frontend/web/js/view/minicart.js
Copy the entire content of this file and save it to a new file with the same name in your Magento 2.4.0 instance.
[magento_root]/app/design/frontend/[your_theme]/Magento_Checkout/web/js/view/minicart.js
This will replace the existing mini cart JavaScript file with the new file.bin/magento c:c && bin/magento c:f
It's essential to test the new mini cart thoroughly before making it live to ensure that it works correctly with your website and theme.
If you run into any issues with your theme after upgrading to Magento 2.4.5, it may be necessary to revert some of your theme files back to use Magento's base files. To do this, you can follow these steps:
Magento offers a powerful though cumbersome templating system that easily allows you to replace sections of your own templates with those found in the latest version of Magento. By comparing the files found within vendor, as seen the above gallery and minicart examples, we can migrate updates or changes into our own theme.