<?php declare(strict_types=1);
namespace FuerstenbergPorzellan\Subscriber;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Content\Product\ProductEvents;
use Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent;
class ListingSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ProductListingCriteriaEvent::class => 'onProductsLoaded'
];
}
public function onProductsLoaded(ProductListingCriteriaEvent $event)
{
$criteria = $event->getCriteria();
$criteria->addAssociation('manufacturer');
}
}