Search code examples
phpsymfonysymfony4shopwareshopware5

Which event is used in backend when deleting an article


I want to know which event is used in Shopware 5 backend when we delete an article, I see in browser's network tab that controller ArticleList method deleteProduct is called

enter image description here

As it says, an "Event listener function of the product store of the backend module"

So my question is, I am making a custom plugin where i have to add some more logic when an article is deleted.

Any event or hook which I can use?


Solution

  • I managed to solve my problem this way, hope it helps someone in the future.

    // subscribe to an event
    public static function getSubscribedEvents()
    {
        return [
            'Enlight_Controller_Action_PostDispatchSecure_Backend_ArticleList' => 'onArticleListPostDispatch'
        ];
    }
    
    // add the logic to your subscribed method
    public function onArticleListPostDispatch(\Enlight_Event_EventArgs $args)
    {
        $controller = $args->getSubject();        
        $request = $controller->Request();
    
        if ($request->getActionName() == 'deleteProduct') {
              
                // add your logic here
        }
    }