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) {