重定向到控制器抛出“不幸的是,出了点问题。”

Rah*_*rot 2 shopware

我已经在开发模板中安装了这个插件https://github.com/shopware/swag-docs-storefront-controller但是当我运行它并试图清除购物车时,它重定向到 url 并显示错误“不幸的是,出了点问题。 ”

在日志中我发现以下错误

request.CRITICAL:未捕获的 PHP 异常 Shopware\Core\Framework\Routing\Exception\InvalidRouteScopeException:“路由 frontend.checkout.clearCart 的路由范围无效。” 在/var/www/html/shopware6/vendor/shopware/platform/src/Core/Framework/Routing/RouteScopeListener.php line 93 {"exception":"[object] (Shopware\Core\Framework\Routing\Exception\InvalidRouteScopeException (代码:0):路由前端的无效路由范围。checkout.clearCart. at /var/www/html/shopware6/vendor/shopware/platform/src/Core/Framework/Routing/RouteScopeListener.php:93)"} [ ]

但是,这在安装程序设置中工作正常。

小智 5

您需要向控制器添加路由范围。自几周前以来这是强制性的,但似乎示例并未根据此进行更改。

https://docs.shopware.com/en/shopware-platform-dev-en/getting-started/recent-updates#routescope-details

将 routescope-annotation 添加到控制器应该就足够了:https : //github.com/shopware/swag-docs-storefront-controller/blob/master/src/Storefront/Controller/ClearCartController.php#L23

只需将其添加到注释中:

 * @RouteScope(scopes={"storefront"})
Run Code Online (Sandbox Code Playgroud)

并添加路由范围:

use Shopware\Core\Framework\Routing\Annotation\RouteScope;
Run Code Online (Sandbox Code Playgroud)

我将准备一个拉请求来修复它。