<?php declare(strict_types=1);
namespace Cogi\Theme\Tulip\Storefront\Subscriber;
use Shopware\Core\Checkout\Shipping\ShippingMethodCollection;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepositoryInterface;
use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ProductSubscriber implements EventSubscriberInterface
{
protected $shippingMethodRepository;
public function __construct(SalesChannelRepositoryInterface $shippingMethodRepository)
{
$this->shippingMethodRepository = $shippingMethodRepository;
}
public static function getSubscribedEvents(): array
{
return [
ProductPageLoadedEvent::class => 'addShippingOptions'
];
}
public function addShippingOptions(ProductPageLoadedEvent $event): void
{
/*
$criteria = (new Criteria())->addFilter(new EqualsFilter('active', true));
$shippingMethods = $this->shippingMethodRepository->search($criteria, $event->getSalesChannelContext())->getEntities();
dump($shippingMethods->filterByActiveRules($event->getSalesChannelContext()));
die('<html><body></body></html>');
*/
}
}