<?php declare(strict_types=1);
namespace GrimmTheme\Storefront\Subscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Content\Product\Events\ProductCrossSellingStreamCriteriaEvent;
use Shopware\Core\Content\Product\Events\ProductCrossSellingIdsCriteriaEvent;
use Shopware\Core\Content\Product\Events\ProductCrossSellingCriteriaEvent; //abstract class
class CrossSellingSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
// one event for dynamic group, one for manual selection
return [
ProductCrossSellingStreamCriteriaEvent::class => 'onCrossSellingCriteria',
ProductCrossSellingIdsCriteriaEvent::class => 'onCrossSellingCriteria'
];
}
public function onCrossSellingCriteria(ProductCrossSellingCriteriaEvent $event)
{
$event->getCriteria()->addAssociation('delivery_time');
}
}