custom/plugins/NrbnLittleVanGogh/src/Subscriber/ListingSubscriber.php line 18

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace NrbnLittleVanGogh\Subscriber;
  4. use Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class ListingSubscriber implements EventSubscriberInterface
  7. {
  8.    public static function getSubscribedEvents(): array
  9.    {
  10.        return [
  11.            ProductListingCriteriaEvent::class => 'handleRequest'
  12.        ];
  13.    }
  14.    public function handleRequest(ProductListingCriteriaEvent $event)
  15.    {
  16.        $page = (int) $event->getRequest()->query->get('p'1);
  17.        #$event->getCriteria()->resetAggregations();
  18.        $event->getCriteria()->addAssociation('manufacturer.media');
  19.        #$event->getCriteria()->setLimit(10);
  20.        #$event->getCriteria()->setOffset(($page - 1) * 10);
  21.        return $event;
  22.    }
  23. }