monsieurbiz / SyliusSearchPlugin

A search plugin using Elasticsearch for Sylius
MIT License
45 stars 38 forks source link

Add an automatic reindex manager to enable or disable event #137

Closed delyriand closed 1 year ago

delyriand commented 1 year ago

For example, when we have an import product service and have multiple flush, we want to send a reindex message at the end manually. Now, is it possible:

...
// Disable the automatic product search reindex
$this->automaticProductReindexManager->shouldAutomaticallyReindex(false);

...
// Dispatch a message to reindex my current product
$productReindexFromIdsMessage = new ProductReindexFromIds();
$productReindexFromIdsMessage->addProductId($product->getId());
$this->messageBus->dispatch($productReindexFromIdsMessage);

// Re-enable the automatic product search reindex
$this->automaticProductReindexManager->shouldAutomaticallyReindex(true);