vendor/store.shopware.com/swagenterprisesearchplatform/src/Manufacturer/ManufacturerUpdater.php line 37

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Swag\EnterpriseSearch\Manufacturer;
  3. use Shopware\Core\Content\Product\Aggregate\ProductManufacturer\ProductManufacturerDefinition;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenEvent;
  6. use Shopware\Elasticsearch\Framework\Indexing\ElasticsearchIndexer;
  7. use Swag\EnterpriseSearch\Common\VersionHelper;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class ManufacturerUpdater implements EventSubscriberInterface
  10. {
  11.     /**
  12.      * @var ElasticsearchIndexer
  13.      */
  14.     private $indexer;
  15.     /**
  16.      * @var EntityDefinition
  17.      */
  18.     private $definition;
  19.     public function __construct(ElasticsearchIndexer $indexerEntityDefinition $definition)
  20.     {
  21.         $this->indexer $indexer;
  22.         $this->definition $definition;
  23.     }
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             ProductManufacturerDefinition::ENTITY_NAME '.written' => 'update',
  28.         ];
  29.     }
  30.     public function update(EntityWrittenEvent $event): void
  31.     {
  32.         if (VersionHelper::isShopware64X()) {
  33.             $this->indexer->updateIds(
  34.                 $this->definition,
  35.                 $event->getIds()
  36.             );
  37.             return;
  38.         }
  39.         $this->indexer->sendIndexingMessages(
  40.             $this->definition,
  41.             $event->getIds()
  42.         );
  43.     }
  44. }