vendor/shopware/platform/src/Elasticsearch/Product/ProductUpdater.php line 29

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.     public static function getSubscribedEvents()
  17.     {
  18.         return [
  19.             ProductIndexerEvent::class => 'update',
  20.         ];
  21.     }
  22.     public function update(ProductIndexerEvent $event): void
  23.     {
  24.         $this->indexer->updateIds(
  25.             $this->definition,
  26.             array_unique(array_merge($event->getIds(), $event->getChildrenIds()))
  27.         );
  28.     }
  29. }