EmicoEcommerce / Magento2Tweakwise-archived

Magento 2 module for Tweakwise integration
Other
9 stars 25 forks source link

Exception when using Category Permissions #69

Closed davekleijnkega closed 5 years ago

davekleijnkega commented 5 years ago

When using category permissions for a category and customer is not logged in then the category page is giving an exception.

Environment

Steps to reproduce

  1. Install Magento with Tweakwise configured
  2. Enable category permissions (Stores -> Configuration -> Catalog -> Catalog -> Category Permissions -> Enable)
  3. Go to category and set permissions (Catalog -> Categories -> Choose category -> Category Permissions -> New Permission) Select All Websites (as Website) -> Retailer (as Group). Allow for browsing, display prices and add to bag options.
  4. On frontend go to the edited category. (Use the full url if menu item is not visible)

Actual result

Exception:

{"0":"Navigation context not set, initialize a version of Emico\\Tweakwise\\Model\\Catalog\\Layer\\NavigationContext first.","1":"<pre>#1 Emico\\Tweakwise\\Model\\Observer\\AbstractProductNavigationRequestObserver->hasTweakwiseResponse() called at [vendor\/emico\/tweakwise\/src\/Model\/Observer\/AbstractProductNavigationRequestObserver.php:93]\n#2 Emico\\Tweakwise\\Model\\Observer\\AbstractProductNavigationRequestObserver->execute(&Magento\\Framework\\Event\\Observer#000000004136546200000000266328aa#) called at [vendor\/magento\/framework\/Event\/Invoker\/InvokerDefault.php:72]\n#3 Magento\\Framework\\Event\\Invoker\\InvokerDefault->_callObserverMethod(&Emico\\Tweakwise\\Model\\Observer\\CatalogLastPageRedirect#000000004136547100000000266328aa#, &Magento\\Framework\\Event\\Observer#000000004136546200000000266328aa#) called at [vendor\/magento\/framework\/Event\/Invoker\/InvokerDefault.php:60]\n#4 Magento\\Framework\\Event\\Invoker\\InvokerDefault->dispatch(array('instance' => 'Emico\\Tweakwise\\...', 'name' => 'emico-tweakwise'), &Magento\\Framework\\Event\\Observer#000000004136546200000000266328aa#) called at [vendor\/magento\/module-staging\/Model\/Event\/Manager.php:97]\n#5 Magento\\Staging\\Model\\Event\\Manager->dispatch('controller_actio...', array('controller_actio...' => &Magento\\Catalog\\Controller\\Category\\View\\Interceptor#00000000413653b400000000266328aa#, 'request' => &Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#)) called at [generated\/code\/Magento\/Staging\/Model\/Event\/Manager\/Proxy.php:95]\n#6 Magento\\Staging\\Model\\Event\\Manager\\Proxy->dispatch('controller_actio...', array('controller_actio...' => &Magento\\Catalog\\Controller\\Category\\View\\Interceptor#00000000413653b400000000266328aa#, 'request' => &Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#)) called at [vendor\/magento\/framework\/App\/Action\/Action.php:112]\n#7 Magento\\Framework\\App\\Action\\Action->dispatch(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/framework\/Interception\/Interceptor.php:58]\n#8 Magento\\Catalog\\Controller\\Category\\View\\Interceptor->___callParent('dispatch', array(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#)) called at [vendor\/magento\/framework\/Interception\/Interceptor.php:138]\n#9 Magento\\Catalog\\Controller\\Category\\View\\Interceptor->Magento\\Framework\\Interception\\{closure}(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/module-customer-segment\/Model\/App\/Action\/ContextPlugin.php:81]\n#10 Magento\\CustomerSegment\\Model\\App\\Action\\ContextPlugin->aroundDispatch(&Magento\\Catalog\\Controller\\Category\\View\\Interceptor#00000000413653b400000000266328aa#, &Closure#00000000413653b500000000266328aa#, &Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/framework\/Interception\/Interceptor.php:135]\n#11 Magento\\Catalog\\Controller\\Category\\View\\Interceptor->Magento\\Framework\\Interception\\{closure}(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]\n#12 Magento\\Catalog\\Controller\\Category\\View\\Interceptor->___callPlugins('dispatch', array(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#), NULL) called at [generated\/code\/Magento\/Catalog\/Controller\/Category\/View\/Interceptor.php:39]\n#13 Magento\\Catalog\\Controller\\Category\\View\\Interceptor->dispatch(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/framework\/App\/FrontController.php:55]\n#14 Magento\\Framework\\App\\FrontController->dispatch(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/framework\/Interception\/Interceptor.php:58]\n#15 Magento\\Framework\\App\\FrontController\\Interceptor->___callParent('dispatch', array(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#)) called at [vendor\/magento\/framework\/Interception\/Interceptor.php:138]\n#16 Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/module-store\/App\/FrontController\/Plugin\/RequestPreprocessor.php:94]\n#17 Magento\\Store\\App\\FrontController\\Plugin\\RequestPreprocessor->aroundDispatch(&Magento\\Framework\\App\\FrontController\\Interceptor#000000004136514800000000266328aa#, &Closure#000000004136514900000000266328aa#, &Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/framework\/Interception\/Interceptor.php:135]\n#18 Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/module-page-cache\/Model\/App\/FrontController\/BuiltinPlugin.php:69]\n#19 Magento\\PageCache\\Model\\App\\FrontController\\BuiltinPlugin->aroundDispatch(&Magento\\Framework\\App\\FrontController\\Interceptor#000000004136514800000000266328aa#, &Closure#000000004136514900000000266328aa#, &Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/framework\/Interception\/Interceptor.php:135]\n#20 Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]\n#21 Magento\\Framework\\App\\FrontController\\Interceptor->___callPlugins('dispatch', array(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#), NULL) called at [generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php:26]\n#22 Magento\\Framework\\App\\FrontController\\Interceptor->dispatch(&Magento\\Framework\\App\\Request\\Http#000000004136504100000000266328aa#) called at [vendor\/magento\/framework\/App\/Http.php:136]\n#23 Magento\\Framework\\App\\Http->launch() called at [generated\/code\/Magento\/Framework\/App\/Http\/Interceptor.php:24]\n#24 Magento\\Framework\\App\\Http\\Interceptor->launch() called at [vendor\/magento\/framework\/App\/Bootstrap.php:257]\n#25 Magento\\Framework\\App\\Bootstrap->run(&Magento\\Framework\\App\\Http\\Interceptor#00000000413650ec00000000266328aa#) called at [index.php:77]\n<\/pre>","url":"\/vip.html","script_name":"\/index.php"}

Expected result

Customer is redirected to the 404 not found page. (default value under Category Permissions config)

edwinljacobs commented 5 years ago

Thanks for the issue, we will look into it

edwinljacobs commented 5 years ago

Hi I created branch: issue/67-exception-category-with-customer-group-restriction with a potential fix for the issue. I took the liberty of refactoring observer definitions since they where getting too "non-straightforward". Could you check if everything works as expected by testing said branch?

pull request is open (if you want to check for details): https://github.com/EmicoEcommerce/Magento2Tweakwise/pull/70

If all is fine it will be merged and released.

With kind regards

davekleijnkega commented 5 years ago

Thanks @edwinljacobs! It works as expected :)

edwinljacobs commented 5 years ago

Hi,

Thanks for testing, good to know that this resolves the issue. We expect the release to be somewhere next week, problably wednesday.

With kind regards

edwinljacobs commented 5 years ago

This has been released in v1.4.11 and also in v2.0.0-beta1.

With kind regards

davekleijnkega commented 5 years ago

Thanks @edwinljacobs!