# Event is not being called properly

**URL:** https://forum.shopware.com/t/event-is-not-being-called-properly/92720
**Category:** Shopware 6 (English)
**Created:** [2. Februar 2022 um 10:30 UTC](https://forum.shopware.com/t/event-is-not-being-called-properly/92720 "2022-02-02T10:30:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kstar](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kstar](https://forum.shopware.com/u/kstar)
#### Post date: [2. Februar 2022 um 10:30 UTC](https://forum.shopware.com/t/event-is-not-being-called-properly/92720/1 "2022-02-02T10:30:08Z")

</div>

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:

```auto
  <?php

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;
        error_log('onLineItemAdded');
    }
    
    public function beforeLineItemAdded(BeforeLineItemAddedEvent $event) 
    {
        echo 'test';
            $mylineitems = $event->getCart()->getLineItems();
            
        error_log('beforeLineItemAdded');
    }
    
    /**
     * Handles the stuff, that happens on the product detail page
     *
     * @param ProductPageLoadedEvent $event
     */
    public function onProductPageLoaded (ProductPageLoadedEvent $event)
    {
        echo $sqlQuery = "SELECT * FROM `product`";

```

---

<div class="post-metadata">

### Author: ![simplecode](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@simplecode](https://forum.shopware.com/u/simplecode)
#### Post date: [9. Februar 2022 um 17:35 UTC](https://forum.shopware.com/t/event-is-not-being-called-properly/92720/2 "2022-02-09T17:35:52Z")

</div>

I have the same problem. [Here](https://forum.shopware.com/t/how-can-we-set-custom-fields-per-cart-line-item/62122/4) someone used the LineItemAddedEvent which does not exist anymore as it seems (Shopware 6.4.4.1).
