public function reschedule(SubscriberEntity $subscriber) { $tasks = $this->tasksRepository->findByTypeAndSubscriber(AbandonedCartWorker::TASK_TYPE, $subscriber); if (!$tasks) { return; } $this->cancel($subscriber); foreach ($tasks as $task) { $meta = $task->getMeta(); $automation = isset($meta['automation_id']) ? $this->automationStorage->getAutomation((int)$meta['automation_id']) : null; if (!$automation) { continue; } $this->scheduleForSingleAutomation($subscriber, $meta['product_ids'] ?? [], $automation); } } public function cancel(SubscriberEntity $subscriber) { $existingTasks = $this->tasksRepository->findByTypeAndSubscriber(AbandonedCartWorker::TASK_TYPE, $subscriber); if (!$existingTasks) { return; } foreach ($existingTasks as $task) { if ($task->getStatus() !== ScheduledTaskEntity::STATUS_SCHEDULED) { continue; } foreach ($task->getSubscribers() as $taskSubscriber) { $this->taskSubscribersRepository->remove($taskSubscriber); } $this->tasksRepository->remove($task); } $this->tasksRepository->flush(); } } SOUTRAMALL - SOUTRAMARKET