<?php declare(strict_types=1);
namespace Megasol\MegasolBase\Subscriber;
use Megasol\MegasolBase\Struct\MyCustomStruct;
use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Checkout\Customer\CustomerEvents;
use Shopware\Core\Content\Product\ProductEntity;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
use Shopware\Core\System\User\UserEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Content\Product\ProductEvents;
class CheckLoginSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
// Return the events to listen to as array like this: <event to listen to> => <method to execute>
return [
CustomerEvents::CUSTOMER_LOADED_EVENT => 'onCustomerLogin'
];
}
public function onCustomerLogin(EntityLoadedEvent $event): void
{
/** @var CustomerEntity $customerEntity */
/*foreach ($event->getEntities() as $customerEntity) {
//$customerEntity->addExtension('msag_construct', new MyCustomStruct());
dump($customerEntity->getId());
}
*/
}
}