<?php
declare(strict_types=1);
namespace NrbnLittleVanGogh\Subscriber;
use Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ListingSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ProductListingCriteriaEvent::class => 'handleRequest'
];
}
public function handleRequest(ProductListingCriteriaEvent $event)
{
$page = (int) $event->getRequest()->query->get('p', 1);
#$event->getCriteria()->resetAggregations();
$event->getCriteria()->addAssociation('manufacturer.media');
#$event->getCriteria()->setLimit(10);
#$event->getCriteria()->setOffset(($page - 1) * 10);
return $event;
}
}