I have written the code in Community based Plugins as follows:

private function registerEvents()
{
    
    $this->subscribeEvent
    (
        'Enlight_Controller_Action_PostDispatch_Frontend_Detail',
        'onPostDispatchDetail'
    );
     
}
public function onPostDispatchDetail(Enlight_Controller_ActionEventArgs $args) 
{
    //......some other code
    Shopware()->Modules()->Basket()->sAddArticle('101',1);
    //.....some other code
}

At this point it is giving me an error as follows:

Fatal error: Uncaught Shopware\Components\CSRFTokenValidationException: The provided X-CSRF-Token for path "/domain.com/product-sample---software-basis-modul" is invalid. Please go back, reload the page and try again. in /home/domain.com/engine/Shopware/Components/CSRFTokenValidator.php:152 Stack trace: #0

I have already read this documentation and tried the way showing in below guide:

https://developers.shopware.com/developers-guide/csrf-protection/

0

There are 0 best solutions below