<?php
declare(strict_types=1);
namespace Abas\AbasConnector\Subscribers;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Storefront\Event\StorefrontRenderEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class StorefrontRenderSubscriber implements EventSubscriberInterface
{
/**
* TODO: unused property
* @var EntityRepositoryInterface
*/
private $productRepository;
/**
* @param EntityRepositoryInterface $productRepository
*/
public function __construct(EntityRepositoryInterface $productRepository)
{
$this->productRepository = $productRepository;
}
/**
* @inheritDoc
*/
public static function getSubscribedEvents(): array
{
return [
StorefrontRenderEvent::class => [
[
'addProductnumberList'
]
]
];
}
/**
* TODO: leere Methode.
*
* @param StorefrontRenderEvent $event
*
* @return void
*/
public function addProductnumberList(StorefrontRenderEvent $event): void
{
//TODO: Wieder integrieren mit Performance-Optimierung (Per JS-Ajax-Aufruf, Standard-Suche implementieren...)
// $productnumberList = "";
// $criteria = new Criteria();
//
// $products = $this->productRepository
// ->search($criteria, $event->getContext());
//
// foreach($products as $product){
// if($productnumberList != "")
// $productnumberList .= "," . $product->getProductNumber();
// else
// $productnumberList .= $product->getProductNumber();
// }
//
// $event->setParameter('productnumberList', $productnumberList);
}
}