From f4a7ff32899924955effa18453749962d78b316d Mon Sep 17 00:00:00 2001 From: Maxime Leclercq Date: Tue, 20 Sep 2022 16:42:48 +0200 Subject: [PATCH] fix: reset the dispatch flag in the event subscribe on clear event --- src/EventSubscriber/ReindexProductEventSubscriber.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/EventSubscriber/ReindexProductEventSubscriber.php b/src/EventSubscriber/ReindexProductEventSubscriber.php index 40380217..445b0255 100644 --- a/src/EventSubscriber/ReindexProductEventSubscriber.php +++ b/src/EventSubscriber/ReindexProductEventSubscriber.php @@ -63,6 +63,7 @@ public function getSubscribedEvents() return [ Events::onFlush => 'onFlush', Events::postFlush => 'postFlush', + Events::onClear => 'onClear', ]; } @@ -82,7 +83,7 @@ public function postFlush(PostFlushEventArgs $args): void if (!$this->automaticReindexManager->shouldBeAutomaticallyReindex()) { return; } - + $unitOfWork = $args->getEntityManager()->getUnitOfWork(); $this->manageUnitOfWork($unitOfWork); @@ -102,6 +103,11 @@ public function postFlush(PostFlushEventArgs $args): void } } + public function onClear(): void + { + $this->dispatched = false; + } + private function onFlushEntities(array $entities, string $type = 'insertionsOrUpdate'): void { foreach ($entities as $entity) {