custom/plugins/CogiThemeTulip/src/Storefront/Subscriber/ProductSubscriber.php line 29

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Cogi\Theme\Tulip\Storefront\Subscriber;
  3. use Shopware\Core\Checkout\Shipping\ShippingMethodCollection;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
  6. use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepositoryInterface;
  7. use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class ProductSubscriber implements EventSubscriberInterface
  10. {
  11.     protected $shippingMethodRepository;
  12.     public function __construct(SalesChannelRepositoryInterface $shippingMethodRepository)
  13.     {
  14.         $this->shippingMethodRepository $shippingMethodRepository;
  15.     }
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             ProductPageLoadedEvent::class => 'addShippingOptions'
  20.         ];
  21.     }
  22.     public function addShippingOptions(ProductPageLoadedEvent $event): void
  23.     {
  24.         /*
  25.         $criteria = (new Criteria())->addFilter(new EqualsFilter('active', true));
  26.         $shippingMethods = $this->shippingMethodRepository->search($criteria, $event->getSalesChannelContext())->getEntities();
  27.         dump($shippingMethods->filterByActiveRules($event->getSalesChannelContext()));
  28.         die('<html><body></body></html>');
  29.         */
  30.     }
  31. }