Search code examples
cronshopware

How to set up a Cronjob for auto-import of Data in Shopware 5


I've been struggling to figure out how to set up cronjobs for Shopware 5 in general.

The documentation does not provide enough information to set cronjobs up from scratch, I've also asked for some help on their official slack channel but have not been answered at all.

As someone who is new to shopware and the concept of cronjobs, I've been having a lot of trouble finding a solution to my problem. I'd like to be pointed in the right direction since I've been shooting arrows in the dark at this point.


Solution

  • Cronjobs in Shopware 5 are pretty well documented here.

    First of all you need to install and activate the "Cron" plugin in the Plugin Manager. It is required to run cronjobs in Shopware 5. Then you can configure the cronjobs in Configuration > Basic Settings > System > Cronjobs.

    But this is not enough, you have to trigger the cronjobs from your OS. How you can do this depends on your hosting provider. Some hosting plans doesn't allow to configure cronjobs. So you have to contact your hosting provider to find out if you can configure cronjobs and how to do this.

    The recommended way to execute cronjobs is via shell, as described in the documentation:

    php bin/console sw:cron:run
    

    By "auto-import of data" you probably mean to use the Import/Export plugin. The plugin provides its own cronjob "CronAutoImport", which you can configure in settings. According to the documentation you have to deposit your CSV or XML files in the directory files/import_cron/ and include the profile name you want to use in the filename. The files will be imported automatically.