shopwareshopware6cron-taskshopware6-appshopware6-api

How to use scheduled tasks with app infrastructure?


we created a custom entity API within an app infrastructure and would like to have a cronjob, deleting all entries older that particular number of days. Is there an App (cloud) way to register such a task?

Otherwise I see two options: either register a cron-task within the App server which will regularly get a list of all entries from the custom entity API and would delete one by one all entries older than the defined number of days. However, this is obviously not optimal if there are many entries. Other way, I guess, would be to use the plugin way of defining a Scheduled Task Class. But this is hardly API based approach. Is there any resolution/best practice experiences to this?


Solution

  • Otherwise I see two options: either register a cron-task within the App server which will regularly get a list of all entries from the custom entity API and would delete one by one all entries older than the defined number of days. However, this is obviously not optimal if there are many entries.

    This would be the way to go with apps. However you don't have to delete the entities one by one. You can use the /api/_action/sync endpoint to bulk delete multiple entities at once.