<?php
/**
* @author Christian Reinelt <c.reinelt@mediagraphik.de>
* @copyright (c) Mediagraphik GmbH
*/
namespace MegaParentProductListing\Subscriber;
use MegaParentProductListing\Components\Product\ParentProductPriceCalculator;
use Shopware\Core\Content\Product\Events\ProductCrossSellingIdsCriteriaEvent;
use Shopware\Core\Content\Product\Events\ProductCrossSellingsLoadedEvent;
use Shopware\Core\Content\Product\Events\ProductCrossSellingStreamCriteriaEvent;
use Shopware\Core\Content\Product\Events\ProductListingResultEvent;
use Shopware\Core\Content\Product\Events\ProductSearchResultEvent;
use Shopware\Core\Content\Product\Events\ProductSuggestResultEvent;
use Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity;
use Shopware\Core\System\SalesChannel\Entity\SalesChannelEntityLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ProductSubscriber implements EventSubscriberInterface
{
/**
* @var ParentProductPriceCalculator
*/
private $calculator;
public function __construct(ParentProductPriceCalculator $calculator)
{
$this->calculator = $calculator;
}
public static function getSubscribedEvents()
{
return [
'sales_channel.product.loaded' => 'loaded'
];
}
public function loaded(SalesChannelEntityLoadedEvent $event): void
{
$this->calculator->calculate($event->getEntities(), $event->getSalesChannelContext());
}
}