custom/static-plugins/AbasConnector/src/Subscribers/StorefrontRenderSubscriber.php line 48

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Abas\AbasConnector\Subscribers;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  5. use Shopware\Storefront\Event\StorefrontRenderEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class StorefrontRenderSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * TODO: unused property
  11.      * @var EntityRepositoryInterface
  12.      */
  13.     private $productRepository;
  14.     /**
  15.      * @param EntityRepositoryInterface $productRepository
  16.      */
  17.     public function __construct(EntityRepositoryInterface $productRepository)
  18.     {
  19.         $this->productRepository $productRepository;
  20.     }
  21.     /**
  22.      * @inheritDoc
  23.      */
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             StorefrontRenderEvent::class => [
  28.                 [
  29.                     'addProductnumberList'
  30.                 ]
  31.             ]
  32.         ];
  33.     }
  34.     /**
  35.      * TODO: leere Methode.
  36.      *
  37.      * @param StorefrontRenderEvent $event
  38.      *
  39.      * @return void
  40.      */
  41.     public function addProductnumberList(StorefrontRenderEvent $event): void
  42.     {
  43.         //TODO: Wieder integrieren mit Performance-Optimierung (Per JS-Ajax-Aufruf, Standard-Suche implementieren...)
  44.         //        $productnumberList = "";
  45.         //        $criteria = new Criteria();
  46.         //
  47.         //        $products = $this->productRepository
  48.         //            ->search($criteria, $event->getContext());
  49.         //
  50.         //        foreach($products as $product){
  51.         //            if($productnumberList != "")
  52.         //                $productnumberList .= "," . $product->getProductNumber();
  53.         //            else
  54.         //                $productnumberList .= $product->getProductNumber();
  55.         //        }
  56.         //
  57.         //        $event->setParameter('productnumberList', $productnumberList);
  58.     }
  59. }