<?php
/**
* @author Christian Reinelt <c.reinelt@mediagraphik.de>
* @copyright (c) Mediagraphik GmbH
*/
namespace MegaParentProductListing\Subscriber;
use MegaParentProductListing\Components\Product\DataAbstractionLayer\ParentSalesUpdater;
use Shopware\Core\Content\Product\Events\ProductIndexerEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ProductIndexerSubscriber implements EventSubscriberInterface
{
/**
* @var ParentSalesUpdater
*/
private $parentSalesUpdater;
public function __construct(ParentSalesUpdater $parentSalesUpdater)
{
$this->parentSalesUpdater = $parentSalesUpdater;
}
public static function getSubscribedEvents()
{
return [
ProductIndexerEvent::class => 'updateParentSales'
];
}
public function updateParentSales(ProductIndexerEvent $event)
{
$this->parentSalesUpdater->update($event->getParentIds(),$event->getContext());
}
}