lyra / plugin-magento

An open source plugin that links Magento based e-commerce websites to PayZen secure payment gateway developed by Lyra Network.
https://lyra.com/fr/guides/magento/
Open Software License 3.0
10 stars 12 forks source link

NoSuchEntityException During Checkout #16

Closed sprankhub closed 4 years ago

sprankhub commented 4 years ago

I get the following error when I am about to be redirected to PayZen:

{"0":"Keine Eintrag mit id = 5031","1":"<pre>#1 Magento\\Catalog\\Model\\CategoryRepository->get() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:58]\n#2 Magento\\Catalog\\Model\\CategoryRepository\\Interceptor->___callParent() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:138]\n#3 Magento\\Catalog\\Model\\CategoryRepository\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]\n#4 Magento\\Catalog\\Model\\CategoryRepository\\Interceptor->___callPlugins() called at [generated\/code\/Magento\/Catalog\/Model\/CategoryRepository\/Interceptor.php:26]\n#5 Magento\\Catalog\\Model\\CategoryRepository\\Interceptor->get() called at [vendor\/lyranetwork\/module-payzen\/Helper\/Checkout.php:260]\n#6 Lyranetwork\\Payzen\\Helper\\Checkout->setCartData() called at [vendor\/lyranetwork\/module-payzen\/Model\/Method\/Payzen.php:339]\n#7 Lyranetwork\\Payzen\\Model\\Method\\Payzen->getFormFields() called at [vendor\/lyranetwork\/module-payzen\/Controller\/Processor\/RedirectProcessor.php:50]\n#8 Lyranetwork\\Payzen\\Controller\\Processor\\RedirectProcessor->execute() called at [vendor\/lyranetwork\/module-payzen\/Controller\/Payment\/Redirect.php:67]\n#9 Lyranetwork\\Payzen\\Controller\\Payment\\Redirect->execute() called at [vendor\/magento\/framework\/App\/Action\/Action.php:108]\n#10 Magento\\Framework\\App\\Action\\Action->dispatch() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:58]\n#11 Lyranetwork\\Payzen\\Controller\\Payment\\Redirect\\Interceptor->___callParent() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:138]\n#12 Lyranetwork\\Payzen\\Controller\\Payment\\Redirect\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]\n#13 Lyranetwork\\Payzen\\Controller\\Payment\\Redirect\\Interceptor->___callPlugins() called at [generated\/code\/Lyranetwork\/Payzen\/Controller\/Payment\/Redirect\/Interceptor.php:26]\n#14 Lyranetwork\\Payzen\\Controller\\Payment\\Redirect\\Interceptor->dispatch() called at [vendor\/magento\/framework\/App\/FrontController.php:159]\n#15 Magento\\Framework\\App\\FrontController->processRequest() called at [vendor\/magento\/framework\/App\/FrontController.php:99]\n#16 Magento\\Framework\\App\\FrontController->dispatch() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:58]\n#17 Magento\\Framework\\App\\FrontController\\Interceptor->___callParent() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:138]\n#18 Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/module-store\/App\/FrontController\/Plugin\/RequestPreprocessor.php:94]\n#19 Magento\\Store\\App\\FrontController\\Plugin\\RequestPreprocessor->aroundDispatch() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:135]\n#20 Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/module-page-cache\/Model\/App\/FrontController\/BuiltinPlugin.php:69]\n#21 Magento\\PageCache\\Model\\App\\FrontController\\BuiltinPlugin->aroundDispatch() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:135]\n#22 Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]\n#23 Magento\\Framework\\App\\FrontController\\Interceptor->___callPlugins() called at [generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php:26]\n#24 Magento\\Framework\\App\\FrontController\\Interceptor->dispatch() called at [vendor\/magento\/framework\/App\/Http.php:137]\n#25 Magento\\Framework\\App\\Http->launch() called at [vendor\/magento\/framework\/App\/Bootstrap.php:261]\n#26 Magento\\Framework\\App\\Bootstrap->run() called at [pub\/index.php:40]\n<\/pre>","url":"\/payzen\/payment\/redirect\/","script_name":"\/index.php"}

The issue is that somehow, my product has a category assigned, which does not exist anymore. Even though this should not happen, you should handle it. So here:

https://github.com/lyra/plugin-magento/blob/4a9190b6535a8efb85114e8ecc8b05517f9961af/Helper/Checkout.php#L258-L268

You should really have a try-catch-block, which handles NoSuchEntityException correctly.

Could you please fix this?

nabil509 commented 4 years ago

Hi,

OK. We will fix it in our new version, even we think this is due to an inconsistant database.

I created an issue in our internal reporting tool.

nabil509 commented 4 years ago

Exception managed in v2.4.4 published just now. I close issue.