custom/plugins/fourtwosixattachments/src/Subscriber/ProductCriteriaSubscriber.php line 19

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Fourtwosix\Attachments\Subscriber;
  4. use Shopware\Storefront\Page\Product\ProductPageCriteriaEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class ProductCriteriaSubscriber implements EventSubscriberInterface
  7. {
  8.     public static function getSubscribedEvents(): array
  9.     {
  10.         return [
  11.             ProductPageCriteriaEvent::class => 'addAssociations',
  12.         ];
  13.     }
  14.     public function addAssociations(ProductPageCriteriaEvent $event): void
  15.     {
  16.         $criteria $event->getCriteria();
  17.         $criteria->addAssociation('attachments.media');
  18.         $criteria->addAssociation('attachments.languages');
  19.     }
  20. }