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.
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
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.
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.
A list of all possible commands is printed when entering the following command:
php bin/console
sw:thumbnail:cleanup | Deletes thumbnails that lack their original (full size) image file. |
sw:thumbnail:generate | Generates a new thumbnail. |
sw:generate:attributes | Generates attribute models. |
sw:warm:http:cache | Warms up http cache |
sw:media:cleanup | Collects unused media and moves it to the trashbin. |
sw:snippets:find:missing | Finds missing snippets in the database and dumps them into .ini files |
sw:snippets:remove | Removes snippets from the database. Applicable for a specified folder |
sw:snippets:to:db | Loads snippets from the "/snippets" folder in your installation's main directory to the database. To find the folder, click here |
sw:snippets:to:ini | Dump snippets from the database into .ini files |
sw:snippets:to:sql | Load snippets from .ini files into sql files |
sw:plugin:activate | Activates a plugin. |
sw:plugin:config:list | Lists plugin configurations. |
sw:plugin:config:set | Sets plugin configurations. |
sw:plugin:deactivate | Deactivates a plugin. |
sw:plugin:delete | Deletes a plugin. |
sw:plugin:install | Installs a plugin. |
sw:plugin:list | Lists plugins. |
sw:plugin:refresh | Refreshes plugin list. |
sw:plugin:uninstall | Uninstalls a plugin. |
sw:plugin:update | Updates a plugin. |
If you want to build your own commands, take a look at this: DevDocs.