Event is not being called properly

I have implemented a BeforeLineItemAddedEvent subscriber event, but it’s not getting called. ProductPageLoadedEvent is called properly but BeforeLineItemAddedEvent or AfterLineItemAddedEvent is not called Can anyone let me know what’s wrong with this

here is my Subscriber class:


namespace KiranPlugin\Subscriber;

use Shopware\Core\Checkout\Cart\Event\BeforeLineItemAddedEvent;
use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
use Shopware\Core\Checkout\Cart\Event\AfterLineItemAddedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class KiranSubscriber implements EventSubscriberInterface

    public static function getSubscribedEvents(): array
        return [
            BeforeLineItemAddedEvent::class  => 'beforeLineItemAdded',
            ProductPageLoadedEvent::class => 'onProductPageLoaded',
            AfterLineItemAddedEvent::class  => 'onLineItemAdded',

    public function onLineItemAdded(AfterLineItemAddedEvent $event) 
        echo 1;
    public function beforeLineItemAdded(BeforeLineItemAddedEvent $event) 
        echo 'test';
            $mylineitems = $event->getCart()->getLineItems();
     * Handles the stuff, that happens on the product detail page
     * @param ProductPageLoadedEvent $event
    public function onProductPageLoaded (ProductPageLoadedEvent $event)
        echo $sqlQuery = "SELECT * FROM `product`";

I have the same problem. Here someone used the LineItemAddedEvent which does not exist anymore as it seems (Shopware