custom/plugins/EmovaProductPlugin/src/Subscriber/EmovaProductSubscriber.php line 33

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace EmovaProductPlugin\Subscriber;
  3. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Shopware\Core\Content\Product\ProductEvents;
  6. use Shopware\Core\Framework\Adapter\Monolog\ShopwareLogger;
  7. use Psr\Log\LoggerInterface;
  8. class EmovaProductSubscriber implements EventSubscriberInterface
  9. {
  10.     /**
  11.      * @var ShopwareLogger
  12.      */
  13.     private LoggerInterface $logger;
  14.     public function __construct(
  15.         LoggerInterface $logger
  16.     ) {
  17.         $this->logger $logger;
  18.         $this->logger->warning('EmovaProductPlugin: constructor was called.');
  19.     }
  20.     public static function getSubscribedEvents(): array
  21.     {
  22.         // Return the events to listen to as array like this:  <event to listen to> => <method to execute>
  23.         return [
  24.             ProductEvents::PRODUCT_LOADED_EVENT => 'onProductsLoaded'
  25.         ];
  26.     }
  27.     public function onProductsLoaded(EntityLoadedEvent $event)
  28.     {
  29.         // Do something
  30.         // E.g. work with the loaded entities: $event->getEntities()
  31.         $this->logger->warning('EmovaProductPlugin: onProdLoaded was called.');
  32.     }
  33. }