custom/plugins/WxLoadVariants/src/Subscriber/MySubscriber.php line 17

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Wx\LoadVariants\Subscriber;
  3. use Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. class MySubscriber implements EventSubscriberInterface
  6. {
  7.     public static function getSubscribedEvents(): array
  8.     {
  9.         return [
  10.             ProductListingCriteriaEvent::class => 'handleRequest',
  11.         ];
  12.     }
  13.     public function handleRequest(ProductListingCriteriaEvent $event): void
  14.     {
  15.         $event
  16.             ->getCriteria()
  17.             ->addAssociation('children');
  18.         /*
  19.         $event
  20.             ->getCriteria()
  21.             ->addAssociation('children.media');
  22.         */
  23.         $event
  24.             ->getCriteria()
  25.             ->addAssociation('children.options');
  26.     }
  27. }