PrestaShop is a free and open-source content management system designed for building online e-commerce stores from scratch. It is designed to enable businesses ranging from small companies to large corporations to create online stores.
In March 2022, they released the latest stable version of Prestashop, Prestashop 8, completely changing many features and refreshing the design in most areas.
Many Prestashop customers today decide to upgrade their e-commerce store to the latest version but find it difficult to complete the upgrade successfully, so here is an article on how to upgrade it step by step using the CLI (command line).
Take a Snapshot of the Virtual Server in Question
Before starting the Prestashop version upgrade, it is very important to take a Snapshot of the server in question, since without a Snapshot, you could lose all your website's information and be unable to recover it.
Download the Version
The first step is to check the latest version at https://github.com/PrestaShop/PrestaShop/releases .
The download is performed from the command line, as shown here with version 8.0.2:
wget -O prestashop-upgrade.zip https://github.com/PrestaShop/PrestaShop/releases/download/8.0.2/prestashop_8.0.2.zipExtract Files
Extract the files from the folder using the "unzip" command in the Ubuntu terminal:
unzip prestashop-upgrade.zip && unzip prestashop.zipOnce you have folders such as "classes/", "modules/", "themes/",... you can continue to the next step.
Clean Up Sample Files
Avoid overwriting production resources (images, conf ...) with default data. These folders can be removed from the new version:
img/
override/
Important
All other files present in the new version will overwrite existing files. Any changes you have made to the original source code will be lost (this is not recommended; you should never modify core files).
You will also need to rename the "admin" folder to match the name of your store's admin folder. This will prevent unwanted duplication of administration content.
Enable Maintenance Mode
This can be done from the administration panel:
PrestaShop >= 1.7, under Parámetros de la tienda > Configuración > Pestaña Mantenimiento > Habilitar tienda
Disable the Cache
If you have enabled a caching system (for example, Memcache) in your store, make sure to disable it under "Parámetros avanzados" > "Rendimiento". You can enable it again once the upgrade process is complete. You can also delete the folders var/cache/prod and var/cache/dev.
Important
Note about the vendor folder: Previous PrestaShop 1.7 upgrades showed that conflicts can occur when merging the new vendor/ folder with the old one. To avoid this problem, we recommend deleting this folder from the existing store before copying the new one.
rm -rf vendor/
The next step is to copy the contents of the new folder from the terminal:
cp -R <ruta_a_la_nueva_carpeta>/* <ruta_a_la_actual_tienda>/Example:
cp -R ~/Descargas/prestashop/* /var/www/html/Upgrade the Database
Once the files have been copied, the store's database is ready to be upgraded.
When you are ready, run the file upgrade/upgrade.php from the autoupgrade module using the server's CLI:
php modules/autoupgrade/upgrade/upgrade.phpOnce it has run, an XML log will be displayed. The results are in the attribute result of the first tag <action>:
ok: if updates have been found and executed
error: if something went wrong
info: for subsequent actions, showing details of the process
When the upgrade script finds updates to apply, the SQL queries executed will be listed along with their respective results.
<?xml version="1.0" encoding="UTF-8"?><action result="ok" id=""><action result="info" id="1.7.0.5"><!
<action result="info" id="1.7.0.5"><![CDATA[[OK] PHP 1.7.0.5 : /* PHP:ps_update_tabs(); */]]></action>
<action result="info" id="1.7.0.5"><![CDATA[[OK] SQL 1.7.0.5 : ALTER TABLE `ps_currency` MODIFY `name` varchar(64) NOT NULL]]></action>
<action result="info" id="1.7.1.0"><![CDATA[[OK] SQL 1.7.1.0 : SET SESSION sql_mode = '']]></action>
<action result="info" id="1.7.1.0"><![CDATA[[OK] SQL 1.7.1.0 : SET NAMES 'utf8']]></action>
You can check that each action is marked as "OK". If not, additional details will be displayed after the query, which may help you troubleshoot the problem and run the query again manually in the database. In some cases, you may need to restore the database backup and start over.
An error code may also appear. Each code is associated with a message described here:
Error #27: The store is running a newer version than the content provided by the installation folder.
Error #28: The store is already on the version you are trying to upgrade to.
Error #29: The current version could not be found. Check your database parameters file and the connection to the database.
Error #31: The upgrade directory cannot be found in the installation path. Does the install/upgrade/sql folder exist, and is it not empty?
Error #32: No updates need to be applied.
Error #33: Error loading an SQL upgrade file. Check the permissions of the install/upgrade/sql folder.
Error #40: The version provided in the install/install_version.php file is invalid.
Error #43: Error updating the database schema using Doctrine.
Error #44: Error updating translations.
Error #45: Error enabling the theme.
Cleanup
Before continuing, a few things need to be cleaned up.
The installation folder, used to run database upgrades, is no longer needed and can be safely deleted.
When opening your store (in the front office or back office) in the browser, you may notice some visual issues. This may be because old assets are still cached. Reload them by forcing a page refresh (press ctrl+R on Windows / Linux or cmd+R on Mac OS) or clearing your browser's cache.
Update Modules
Your module files were updated when the files were copied; however, many of them may require additional database changes. Check the modules page in the Back Office to see if any updates are pending.
Go to the administration panel and log in. You will notice that the version displayed on the login page has changed. Next, in the menu, click the module page to access its catalog.
We hope this tutorial has helped you 🙂. Remember, if you have questions about this or any other issue related to your servers at Clouding, feel free to write to soporte@clouding.io We're here for whatever you need—just ask!