Today, I will share with you how to upgrade Magento from 2.4.5-p1 to 2.4.6-p3

Step 1. Turn on maintenance mode and backup database and Magento files

First, you must log in SSH account, go to root folder of your Magento and then try the command lines.

1.1 Turn on maintenance mode:

php bin/magento maintenance:enable

1.2 Backup database

php -dmemory_limit=2G bin/magento config:set system/backup/functionality_enabled 1

php -dmemory_limit=2G bin/magento setup:backup --db

1.3 backup code

php -dmemory_limit=2G bin/magento setup:backup --code

Or you can try zip all Magento files by command line

zip -r public_html public_html

With public_html is folder of your Magento

Step 2. Change version PHP and upgrade source code by composer

Before going to this step, you must install composer on your server.

2.1 Change version of PHP

Change version of PHP to 8.1 or 8.2

2.2 backup file composer.json

cp composer.json composer.json.bak

2.3 Update file composer.json

Run command line:

composer require magento/product-community-edition 2.4.6-p3 --no-update

Then you need to update file composer.json

From:

"require": {
        "dotmailer/dotmailer-magento2-extension": "4.5.1 as 4.4.0",
        "facebook/php-business-sdk": "^9.0",
        "magento/product-community-edition": "2.4.6-p3",
        "olegkoval/magento2-regenerate-url-rewrites": "^1.5",
        "scommerce/core": "^2.0"
    },

To

"require": {
        "facebook/php-business-sdk": "^9.0",
        "magento/product-community-edition": "2.4.6-p3",
        "olegkoval/magento2-regenerate-url-rewrites": "^1.5",
        "scommerce/core": "^2.0"
    },

From

"require-dev": {
        "allure-framework/allure-phpunit": "~1.2.0",
        "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
        "friendsofphp/php-cs-fixer": "~2.14.0",
        "lusitanian/oauth": "~0.8.10",
        "magento/magento-coding-standard": "*",
        "magento/magento2-functional-testing-framework": "~2.6.4",
        "pdepend/pdepend": "2.5.2",
        "phpcompatibility/php-compatibility": "^9.3",
        "phpmd/phpmd": "@stable",
        "phpstan/phpstan": "^0.12.2",
        "phpunit/phpunit": "~6.5.0",
        "sebastian/phpcpd": "~3.0.0",
        "squizlabs/php_codesniffer": "~3.4.0"
    },

To

"require-dev": {
        "allure-framework/allure-phpunit": "^2",
        "dealerdirect/phpcodesniffer-composer-installer": "^0.7",
        "friendsofphp/php-cs-fixer": "^3.8",
        "lusitanian/oauth": "~0.8.10",
        "magento/magento-coding-standard": "*",
        "magento/magento2-functional-testing-framework": "^4.3.1",
        "pdepend/pdepend": "^2.10",
        "phpcompatibility/php-compatibility": "^9.3",
        "phpmd/phpmd": "@stable",
        "phpstan/phpstan": "^0.12.2",
        "phpunit/phpunit": "^9.5",
        "sebastian/phpcpd": "^6.0",
        "squizlabs/php_codesniffer": "~3.4.0"
    },

2.4 Update source code by command line

composer update

Delete var, static and generated by command lines:

rm -rf var/*
rm -rf pub/static/* 
rm -rf generated/*

Step 3. Configure search engine and run upgrade, deploy, reindex, clean and flush cache by command lines

3.1 Configure search engine

php bin/magento config:set catalog/search/engine elasticsearch7

php bin/magento config:set catalog/search/elasticsearch7_server_hostname "localhost"

php bin/magento config:set catalog/search/elasticsearch7_server_port 9200

Note: You must install elasticsearch before go to the next command line.

3.2 Run the command bellow to upgrade, deploy, reindex, clean and flush cache

php bin/magento setup:upgrade && php bin/magento setup:static-content:deploy -f && php -dmemory_limit=4G bin/magento indexer:reindex && php bin/magento cache:clean && php bin/magento cache:flush

Step 4. Check version and turn off maintenance mode by command lines:

php bin/magento --version

It should shows the new version

php bin/magento maintenance:disable

Now, you finish backup Magento How to upgrade Magento from 2.4.5-p1 to 2.4.6-p3

You need to review all your websie, it can be some bug with the new version with core Magento, theme or your third party extensions. If you need a Magento developer to fix bug or support, you can contact us at Magepow.

If you don’t have time for it or it’s still hard for you. You can buy our upgrade service.

Leave a Reply

Your email address will not be published. Required fields are marked *

Trending