custom/plugins/TomRocketsTheme/src/Subscriber/ProductListingLoader.php line 24

Open in your IDE?
  1. <?php
  2. namespace TomRockets\Subscriber;
  3. use Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent;
  4. use Shopware\Core\Content\Product\Events\ProductListingResultEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class ProductListingLoader implements EventSubscriberInterface
  7. {
  8.     /**
  9.      * @inheritDoc
  10.      */
  11.     public static function getSubscribedEvents()
  12.     {
  13.         return [
  14.             ProductListingCriteriaEvent::class => 'onListingLoad'
  15.         ];
  16.     }
  17.     public function onListingLoad(ProductListingCriteriaEvent $event)
  18.     {
  19.         $event->getCriteria()->addAssociation('manufacturer.media');
  20.     }
  21. }