<?php
declare(strict_types=1);
namespace Fourtwosix\Attachments\Subscriber;
use Shopware\Storefront\Page\Product\ProductPageCriteriaEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ProductCriteriaSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ProductPageCriteriaEvent::class => 'addAssociations',
];
}
public function addAssociations(ProductPageCriteriaEvent $event): void
{
$criteria = $event->getCriteria();
$criteria->addAssociation('attachments.media');
$criteria->addAssociation('attachments.languages');
}
}