Back

Upgrading Magento 2.3 to 2.4

I am running my petshop store on magento platform and recently I have decided to upgrade from 2.3.5 to 2.4.3 and even today I am confused if I have made the right decision or not.

Steps to Magento Upgrade from 2.3.X to 2.4.3

If you are working on a live website make sure that you have a backup of the website and database or that your hosting can restore your store. I have learned the hard way that my hosting provider didn’t create any backup for years since I launched my online store therefore I had no option available but to make it work.

Make a cup of tea and be prepare to fail before you can succed. 

Put your website on maintenance mode if your store is live.

				
					php bin/magento maintenance:enable


				
			

If you are upgrading on local machine grab backup composer.json. No need for step 1

				
					cp composer.json composer.json.bak

				
			

Update the composer plugin & update composer.json to the most recent version

				
					composer require magento/composer-root-update-plugin=~1.0 --no-update 

				
			
				
					composer update
				
			

Update Magento to 2.4.3 or the desired version

				
					composer require magento/product-community-edition=2.4.3 --no-update
				
			

Update composer

				
					composer update
				
			

Clear cache and regenerate code.

				
					php bin/magento cache:clean
rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf generated/code/*
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
				
			

Turn off maintenance mode

				
					php bin/magento maintenance:disable
				
			

Be ready to handle all types of errors

Firstly, I have deleted composer.lock and updated the composer.json following the demo in Magento 2 GitHub. I have updated the versions under required_dev {….} and afterward, I ran all the commands above.

Always make a backup of the files before you remove or edit.

I kept switching between PHP versions from Cpanel. I started with PHP v 8.0 and I downgraded to 7.4. I found this version of PHP the most stable for Magento 2.

Apparently, from version 2.4 the elasticsearch has to be installed, ideally prior to the installation but you can still follow along. The elasticsearch error might occur when you run: bin/magento setup:upgrade. You can check what type of search your Magento catalog is using by running the following command:

				
					php bin/magento config:show catalog/search/engine

				
			

If the result is anything else but ‘elasticsearch7’ then its not ok and requires to properly set it up. My result was ‘mysql’ but the solution is really simple:

				
					php bin/magento config:set catalog/search/engine elasticsearch7
php bin/magento config:set catalog/search/elasticsearch7_server_hostname <elasticsearch_hostname>
php bin/magento config:set catalog/search/elasticsearch7_server_port <elasticsearch_port>
				
			

Make sure you replace <elasticsearch_hostname> and <elasticsearch_port> to your actual Elasticsearch connection data.

Conclusion

Magento 2 is not easy to handle but it’s not impossible. Resolving its errors increased your confidence as a developer (LOL) but it’s a waste of time, energy, and effort. 

Adobe announces it won’t support the Magento community anymore and it’s in the hands of the community, therefore, I personally can view the end of it, although it’s the same Magento community that made it rise in the first place. 

We use cookies to give you the best experience. Cookie Policy