vendor/shopware/elasticsearch/Product/ProductUpdater.php line 32

Open in your IDE?
  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\Elasticsearch\Framework\Indexing\ElasticsearchIndexer;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class ProductUpdater implements EventSubscriberInterface
  8. {
  9.     private ElasticsearchIndexer $indexer;
  10.     private EntityDefinition $definition;
  11.     public function __construct(ElasticsearchIndexer $indexerEntityDefinition $definition)
  12.     {
  13.         $this->indexer $indexer;
  14.         $this->definition $definition;
  15.     }
  16.     /**
  17.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  18.      */
  19.     public static function getSubscribedEvents()
  20.     {
  21.         return [
  22.             ProductIndexerEvent::class => 'update',
  23.         ];
  24.     }
  25.     public function update(ProductIndexerEvent $event): void
  26.     {
  27.         $this->indexer->updateIds(
  28.             $this->definition,
  29.             array_unique(array_merge($event->getIds(), $event->getChildrenIds()))
  30.         );
  31.     }
  32. }