custom/plugins/MoorlFoundation/src/Storefront/Subscriber/ProductListingResultSubscriber.php line 31

  1. <?php declare(strict_types=1);
  2. namespace MoorlFoundation\Storefront\Subscriber;
  3. use MoorlFoundation\Core\Service\EntitySearchService;
  4. use MoorlFoundation\Core\Service\EntitySuggestService;
  5. use Shopware\Core\Content\Product\Events\ProductSearchResultEvent;
  6. use Shopware\Core\Content\Product\Events\ProductSuggestResultEvent;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class ProductListingResultSubscriber implements EventSubscriberInterface
  9. {
  10.     private readonly EntitySuggestService $suggestService;
  11.     public function __construct(
  12.         private readonly EntitySearchService $searchService,
  13.         EntitySuggestService $suggestService
  14.     )
  15.     {
  16.         $this->suggestService $suggestService;
  17.     }
  18.     public static function getSubscribedEvents(): array
  19.     {
  20.         return [
  21.             ProductSuggestResultEvent::class => 'onProductSuggestResultEvent',
  22.             ProductSearchResultEvent::class => 'onProductSearchResultEvent',
  23.         ];
  24.     }
  25.     public function onProductSuggestResultEvent(ProductSuggestResultEvent $event): void
  26.     {
  27.         $this->suggestService->enrich($event);
  28.     }
  29.     public function onProductSearchResultEvent(ProductSearchResultEvent $event): void
  30.     {
  31.         $this->searchService->enrich($event);
  32.     }
  33. }