<?php
declare(strict_types=1);
namespace WbfkExtensions\Subscriber;
use Shopware\Core\Content\Product\Events\ProductGatewayCriteriaEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ProductGatewayCriteriaSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ProductGatewayCriteriaEvent::class => 'addMediaToCriteria',
];
}
public function addMediaToCriteria(ProductGatewayCriteriaEvent $event)
{
$event->getCriteria()->addAssociation('media');
}
}