src/Elasticsearch/Product/ProductUpdater.php line 34

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Elasticsearch\Product;
  3. use Shopware\Core\Content\Product\Events\ProductIndexerEvent;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
  5. use Shopware\Core\Framework\Log\Package;
  6. use Shopware\Elasticsearch\Framework\Indexing\ElasticsearchIndexer;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. /**
  9.  * @internal
  10.  */
  11. #[Package('core')]
  12. class ProductUpdater implements EventSubscriberInterface
  13. {
  14.     /**
  15.      * @internal
  16.      */
  17.     public function __construct(private readonly ElasticsearchIndexer $indexer, private readonly EntityDefinition $definition)
  18.     {
  19.     }
  20.     /**
  21.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  22.      */
  23.     public static function getSubscribedEvents(): array
  24.     {
  25.         return [
  26.             ProductIndexerEvent::class => 'update',
  27.         ];
  28.     }
  29.     public function update(ProductIndexerEvent $event): void
  30.     {
  31.         $this->indexer->updateIds($this->definition$event->getIds());
  32.     }
  33. }