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

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\Core\Framework\Log\Package;
  6. use Shopware\Elasticsearch\Framework\Indexing\ElasticsearchIndexer;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. /**
  9. * @deprecated tag:v6.5.0 - reason:becomes-internal - EventSubscribers will become internal in v6.5.0
  10. */
  11. #[Package('core')]
  12. class ProductUpdater implements EventSubscriberInterface
  13. {
  14. private ElasticsearchIndexer $indexer;
  15. private EntityDefinition $definition;
  16. /**
  17. * @internal
  18. */
  19. public function __construct(ElasticsearchIndexer $indexer, EntityDefinition $definition)
  20. {
  21. $this->indexer = $indexer;
  22. $this->definition = $definition;
  23. }
  24. /**
  25. * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  26. */
  27. public static function getSubscribedEvents()
  28. {
  29. return [
  30. ProductIndexerEvent::class => 'update',
  31. ];
  32. }
  33. public function update(ProductIndexerEvent $event): void
  34. {
  35. $this->indexer->updateIds($this->definition, $event->getIds());
  36. }
  37. }