custom/plugins/FuerstenbergPorzellan/src/Subscriber/ListingSubscriber.php line 20

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace FuerstenbergPorzellan\Subscriber;
  3. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Shopware\Core\Content\Product\ProductEvents;
  6. use Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent;
  7. class ListingSubscriber implements EventSubscriberInterface
  8. {
  9.     public static function getSubscribedEvents(): array
  10.     {
  11.         return [
  12.             ProductListingCriteriaEvent::class => 'onProductsLoaded'
  13.         ];
  14.     }
  15.     public function onProductsLoaded(ProductListingCriteriaEvent $event)
  16.     {   
  17.         $criteria $event->getCriteria();
  18.         $criteria->addAssociation('manufacturer');
  19.     }
  20. }