custom/plugins/MegaParentProductListing/src/Subscriber/ProductSubscriber.php line 39

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author Christian Reinelt <c.reinelt@mediagraphik.de>
  4.  * @copyright (c) Mediagraphik GmbH
  5.  */
  6. namespace MegaParentProductListing\Subscriber;
  7. use MegaParentProductListing\Components\Product\ParentProductPriceCalculator;
  8. use Shopware\Core\Content\Product\Events\ProductCrossSellingIdsCriteriaEvent;
  9. use Shopware\Core\Content\Product\Events\ProductCrossSellingsLoadedEvent;
  10. use Shopware\Core\Content\Product\Events\ProductCrossSellingStreamCriteriaEvent;
  11. use Shopware\Core\Content\Product\Events\ProductListingResultEvent;
  12. use Shopware\Core\Content\Product\Events\ProductSearchResultEvent;
  13. use Shopware\Core\Content\Product\Events\ProductSuggestResultEvent;
  14. use Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity;
  15. use Shopware\Core\System\SalesChannel\Entity\SalesChannelEntityLoadedEvent;
  16. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  17. class ProductSubscriber implements EventSubscriberInterface
  18. {
  19.     /**
  20.      * @var ParentProductPriceCalculator
  21.      */
  22.     private $calculator;
  23.     public function __construct(ParentProductPriceCalculator $calculator)
  24.     {
  25.         $this->calculator $calculator;
  26.     }
  27.     public static function getSubscribedEvents()
  28.     {
  29.         return [
  30.             'sales_channel.product.loaded' => 'loaded'
  31.         ];
  32.     }
  33.     public function loaded(SalesChannelEntityLoadedEvent $event): void
  34.     {
  35.         $this->calculator->calculate($event->getEntities(), $event->getSalesChannelContext());
  36.     }
  37. }