Shopware CLI

Article Version

5.5.0 or newer

Table of contents

Shopware offers some useful tools that can be executed via the "console". The so-called "cli" or "shell" commands can be executed without script limitations (for example, the script run time of the server like the php execution time) and are therefore recommended for processing large amounts of data. For the commands to be executed, a terminal software such as "PuTTY" is required, which conveniently is available for free on the internet. Utilizing a terminal program you can use an ssh-connection to access the web server, where commands can be executed.

 

 

The commands can be executed according to the following scheme:

 


bin/console <command>   OR   php bin/console <command>  


Many commands also contain a help function, in which possible parameters are listed.

 


bin/console sw:plugin:list -h  OR  bin/console sw:plugin:list --help

 

Here are some important commands that make your everyday life with "shopware" much easier.

 

Generate thumbnails

If the standard image sizes are changed or new images are added to your database, it is necessary to regenerate the thumbnails. The problem here is that due to script engine limitations, using the provided backend functionalities is only possible if you are processing a very small stack size. Therefore it's recommended to generate the thumbnails using console commands, which still may use a bit of time, depending on the number of images to be processed and the resources available on the server. Generally thumbnails should not be regenerated periodically, because the process requires a lot of performance and is only necessary if new thumbnail sizes are generated or if any images were replaced.

 


php bin/console sw:thumbnail:generate

 

HTTP-Cache warmup

This command is particularly useful as a cronjob, as it considerably reduces the shop's loading times after emptying the cache. This process is not covered by the regular shopware cronjob, so it has to be stored as a separate cronjob in the server console.

 


php bin/console sw:warm:http:cache

 

With the addition "--help" you can display all available options, including the option to empty the existing cache beforehand or to divide the calls into several processes.

For more information and useful commands regarding cronjobs, please see the article Shopware cronjobs. Also, please note that this process may take some time, depending on the number of processed articles or categories. The process is executed automatically for each subshop.

 

Rebuild category tree

In some cases, it might be necessary to rebuild the category tree. However, if you have large amounts of categories or articles hosted in your shop, you should avoid rebuilding the tree via the backend. We strongly recommend to use the console for this.

 


php bin/console sw:rebuild:category:tree

 

Please note that this process may take some time, depending on the number of articles or categories. This process is executed automatically for each subshop.

 

Overview of commands

A list of all possible commands is printed when entering the following command:

 


php bin/console

 

Core commands

sw:thumbnail:cleanupDeletes thumbnails that lack their original (full size) image file.
sw:thumbnail:generateGenerates a new thumbnail.
sw:generate:attributesGenerates attribute models.
sw:warm:http:cacheWarms up http cache
sw:media:cleanupCollects unused media and moves it to the trashbin.
sw:snippets:find:missingFinds missing snippets in the database and dumps them into .ini files
sw:snippets:removeRemoves snippets from the database. Applicable for a specified folder
sw:snippets:to:dbLoads snippets from the "/snippets" folder in your installation's main directory to the database. To find the folder, click here
sw:snippets:to:iniDump snippets from the database into .ini files
sw:snippets:to:sqlLoad snippets from .ini files into sql files

 

Plugin commands

sw:plugin:activateActivates a plugin.
sw:plugin:config:listLists plugin configurations.
sw:plugin:config:setSets plugin configurations.
sw:plugin:deactivateDeactivates a plugin.
sw:plugin:deleteDeletes a plugin.
sw:plugin:installInstalls a plugin.
sw:plugin:listLists plugins.
sw:plugin:refreshRefreshes plugin list.
sw:plugin:uninstallUninstalls a plugin.
sw:plugin:updateUpdates a plugin.

 

Create own commands with a plugin

If you want to build your own commands, take a look at this: DevDocs.