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

Open in your IDE?
  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 EntitySuggestService $suggestService;
  11.     private EntitySearchService $searchService;
  12.     public function __construct(
  13.         EntitySearchService $searchService,
  14.         EntitySuggestService $suggestService
  15.     )
  16.     {
  17.         $this->searchService $searchService;
  18.         $this->suggestService $suggestService;
  19.     }
  20.     public static function getSubscribedEvents(): array
  21.     {
  22.         return [
  23.             ProductSuggestResultEvent::class => 'onProductSuggestResultEvent',
  24.             ProductSearchResultEvent::class => 'onProductSearchResultEvent',
  25.         ];
  26.     }
  27.     public function onProductSuggestResultEvent(ProductSuggestResultEvent $event): void
  28.     {
  29.         $this->suggestService->enrich($event);
  30.     }
  31.     public function onProductSearchResultEvent(ProductSearchResultEvent $event): void
  32.     {
  33.         $this->searchService->enrich($event);
  34.     }
  35. }