custom/plugins/WbfkExtensions/src/Subscriber/ProductGatewayCriteriaSubscriber.php line 20

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace WbfkExtensions\Subscriber;
  4. use Shopware\Core\Content\Product\Events\ProductGatewayCriteriaEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class ProductGatewayCriteriaSubscriber implements EventSubscriberInterface
  7. {
  8.     public static function getSubscribedEvents(): array
  9.     {
  10.         return [
  11.             ProductGatewayCriteriaEvent::class => 'addMediaToCriteria',
  12.         ];
  13.     }
  14.     public function addMediaToCriteria(ProductGatewayCriteriaEvent $event)
  15.     {
  16.         $event->getCriteria()->addAssociation('media');
  17.     }
  18. }