custom/static-plugins/SamsonCustomer/src/Subscriber/ProductSubscriber.php line 34

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Samson\Subscriber;
  3. /***
  4.  *
  5.  * This file is part of the "SAMSON Shop" project.
  6.  *
  7.  * For the full copyright and license information, please read the
  8.  * LICENSE.txt file that was distributed with this source code.
  9.  *
  10.  *  (c) 2020
  11.  *
  12.  ***/
  13. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  14. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
  15. use Shopware\Storefront\Page\Product\ProductPageCriteriaEvent;
  16. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  17. /**
  18.  * Class ProductSubscriber
  19.  * @package Samson\Subscriber
  20.  * @author Artur Seitz <artur.seitz@dkd.de>
  21.  */
  22. class ProductSubscriber implements EventSubscriberInterface
  23. {
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             ProductPageCriteriaEvent::class => 'onProductPageCriteriaEvent'
  28.         ];
  29.     }
  30.     public function onProductPageCriteriaEvent(ProductPageCriteriaEvent $event)
  31.     {
  32.         $criteria $event->getCriteria();
  33.         $criteria->addAssociation('downloadLinks');
  34.         $criteria->getAssociation('downloadLinks')->addFilter(new EqualsFilter('languageId'$event->getSalesChannelContext()->getLanguageId()));
  35.     }
  36. }