forEachFulltextLanguage(function () use ($productIds) { $this->getFulltextElastic()->updateProductFulltext($productIds); $this->getFulltextElastic()->updateProductsAttributes($productIds); }); } protected function updateIndices(string $type = 'all'): void { $this->forEachFulltextLanguage(fn () => $this->getFulltextElastic()->updateIndex($type)); } private function forEachFulltextLanguage(callable $callback) { $this->getContextManager()->deactivateUser(function () use ($callback) { foreach ($this->getFulltextElastic()->getFulltextLanguages() as $language) { $this->getContextManager()->activateContexts([LanguageContext::class => $language->getId()], fn () => $callback(), ); } }); } private function getFulltextElastic(): FulltextElastic { return $this->_fulltextElastic ??= ServiceContainer::getService(FulltextElastic::class); } private function getContextManager(): ContextManager { return $this->_contextManager ??= ServiceContainer::getService(ContextManager::class); } }