custom/plugins/GrimmTheme/src/Storefront/Subscriber/CrossSellingSubscriber.php line 23

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace GrimmTheme\Storefront\Subscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Shopware\Core\Content\Product\Events\ProductCrossSellingStreamCriteriaEvent;
  5. use Shopware\Core\Content\Product\Events\ProductCrossSellingIdsCriteriaEvent;
  6. use Shopware\Core\Content\Product\Events\ProductCrossSellingCriteriaEvent//abstract class
  7. class CrossSellingSubscriber implements EventSubscriberInterface 
  8. {
  9.     public static function getSubscribedEvents(): array
  10.     {
  11.         // one event for dynamic group, one for manual selection
  12.         return [
  13.             ProductCrossSellingStreamCriteriaEvent::class  => 'onCrossSellingCriteria',
  14.             ProductCrossSellingIdsCriteriaEvent::class => 'onCrossSellingCriteria'
  15.         ];
  16.     }
  17.     public function onCrossSellingCriteria(ProductCrossSellingCriteriaEvent $event)
  18.     {
  19.         $event->getCriteria()->addAssociation('delivery_time');
  20.     }
  21. }