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

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace MoorlFoundation\Storefront\Subscriber;
  4. use MoorlFoundation\Core\Service\EntitySearchService;
  5. use MoorlFoundation\Core\Service\EntitySuggestService;
  6. use Shopware\Core\Content\Product\Events\ProductSearchResultEvent;
  7. use Shopware\Core\Content\Product\Events\ProductSuggestResultEvent;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class ProductListingResultSubscriber implements EventSubscriberInterface
  10. {
  11.     private EntitySuggestService $suggestService;
  12.     private EntitySearchService $searchService;
  13.     public function __construct(
  14.         EntitySearchService $searchService,
  15.         EntitySuggestService $suggestService
  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. }