Search code examples
shopware6

Stopping a running scheduled task in shopware6


I would like to know how to stop a running scheduled task in shopware 6. We have some huge integrations and they can be running for several hours updating +500K products. This I would like to be able to stop if I see that the job is not running as expected.


Solution

  • Look in the table scheduled_task for the task you want to deactivate and change the value of the column status to inactive.

    Programmatically:

    $criteria = new Criteria();
    $criteria->addFilter(new EqualsFilter('name', 'name_of_task'));
    // scheduled_task.repository
    $taskId = $this->scheduledTaskRepository->searchIds($criteria, $context)->firstId();
    
    $this->scheduledTaskRepository->update([
        [
            'id' => $taskId,
            'status' => ScheduledTaskDefinition::STATUS_INACTIVE,
        ],
    ], $context);