Magento本地访问购物车页Amasty插件Wrapper类不存在报错
问题描述
访问本地环境checkout/cart购物车页面时触发区块类加载异常,该问题仅在localhost本地环境复现,生产环境运行完全正常,本地已导入生产环境最新的完整数据库转储文件。
已执行的排查操作:
- 清理静态内容
- 清除全量缓存
- 逐一核查CMS页面、静态区块中是否存在对目标类的调用
以上操作均未定位到问题成因。
核心报错信息
Exception #1 (ReflectionException): Class Amasty\Mostviewed\Block\Widget\Wrapper does not exist
完整调用栈
#1 Magento\Framework\Code\Reader\ClassReader->getConstructor() called at [vendor/magento/framework/ObjectManager/Definition/Runtime.php:54] #2 Magento\Framework\ObjectManager\Definition\Runtime->getParameters() called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:100] #3 Magento\Framework\ObjectManager\Factory\Compiled->create() called at [vendor/magento/framework/ObjectManager/ObjectManager.php:56] #4 Magento\Framework\ObjectManager\ObjectManager->create() called at [vendor/magento/framework/View/Element/BlockFactory.php:44] #5 Magento\Framework\View\Element\BlockFactory->createBlock() called at [vendor/magento/framework/View/Layout/Generator/Block.php:272] #6 Magento\Framework\View\Layout\Generator\Block->getBlockInstance() called at [vendor/magento/framework/View/Layout/Generator/Block.php:252] #7 Magento\Framework\View\Layout\Generator\Block->createBlock() called at [vendor/magento/framework/Interception/Interceptor.php:58] #8 Magento\Framework\View\Layout\Generator\Block\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #9 Magento\Framework\View\Layout\Generator\Block\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/amasty/module-fpc-warmer/Plugin/Holepunch/BlockArguments.php:57] #10 Amasty\Fpc\Plugin\Holepunch\BlockArguments->aroundCreateBlock() called at [vendor/magento/framework/Interception/Interceptor.php:135] #11 Magento\Framework\View\Layout\Generator\Block\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #12 Magento\Framework\View\Layout\Generator\Block\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Layout/Generator/Block/Interceptor.php:23] #13 Magento\Framework\View\Layout\Generator\Block\Interceptor->createBlock() called at [vendor/magento/framework/View/Layout/Generator/Block.php:229] #14 Magento\Framework\View\Layout\Generator\Block->generateBlock() called at [vendor/magento/framework/View/Layout/Generator/Block.php:134] #15 Magento\Framework\View\Layout\Generator\Block->process() called at [vendor/magento/framework/View/Layout/GeneratorPool.php:93] #16 Magento\Framework\View\Layout\GeneratorPool->process() called at [vendor/magento/framework/View/Layout.php:365] #17 Magento\Framework\View\Layout->generateElements() called at [vendor/magento/framework/Interception/Interceptor.php:58] #18 Magento\Framework\View\Layout\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #19 Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #20 Magento\Framework\View\Layout\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:32] #21 Magento\Framework\View\Layout\Interceptor->generateElements() called at [vendor/magento/framework/View/Layout/Builder.php:129] #22 Magento\Framework\View\Layout\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Page/Builder.php:65] #23 Magento\Framework\View\Page\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Layout/Builder.php:65] #24 Magento\Framework\View\Layout\Builder->build() called at [vendor/magento/framework/View/Page/Config.php:227] #25 Magento\Framework\View\Page\Config->build() called at [vendor/magento/framework/View/Page/Config.php:250] #26 Magento\Framework\View\Page\Config->getTitle() called at [vendor/magento/module-checkout/Controller/Cart/Index.php:57] #27 Magento\Checkout\Controller\Cart\Index->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58] #28 Magento\Checkout\Controller\Cart\Index\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #29 Magento\Checkout\Controller\Cart\Index\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #30 Magento\Checkout\Controller\Cart\Index\Interceptor->___callPlugins() called at [generated/code/Magento/Checkout/Controller/Cart/Index/Interceptor.php:23] #31 Magento\Checkout\Controller\Cart\Index\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:111] #32 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #33 Magento\Checkout\Controller\Cart\Index\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #34 Magento\Checkout\Controller\Cart\Index\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #35 Magento\Checkout\Controller\Cart\Index\Interceptor->___callPlugins() called at [generated/code/Magento/Checkout/Controller/Cart/Index/Interceptor.php:32] #36 Magento\Checkout\Controller\Cart\Index\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:245] #37 Magento\Framework\App\FrontController->getActionResponse() called at [vendor/magento/framework/App/FrontController.php:212] #38 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:147] #39 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #40 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #41 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:99] #42 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] #43 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/amasty/aminvisiblecaptcha/Plugin/Framework/App/FrontControllerInterface/ValidateCaptcha.php:118] #44 Amasty\InvisibleCaptcha\Plugin\Framework\App\FrontControllerInterface\ValidateCaptcha->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] #45 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:75] #46 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #47 Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #48 Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #49 Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->___callPlugins() called at [generated/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin/Interceptor.php:23] #50 Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] #51 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #52 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:23] #53 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116] #54 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:264] #55 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:30]
解决方案
按以下优先级排查修复:
- 确认本地代码完整性
报错指向Amasty Mostviewed(商品浏览统计/相关商品推荐模块)的Widget区块类不存在,首先检查本地vendor/amasty/module-mostviewed目录是否存在、文件是否完整。生产环境正常但本地报错,大概率是本地拉取代码时该模块文件缺失,直接执行composer install补全全量依赖包,不要仅单独导入数据库。 - 检查模块启用状态
执行以下命令确认Amasty Mostviewed模块已启用:
如果返回模块未启用,执行启用操作:php bin/magento module:status Amasty_Mostviewedphp bin/magento module:enable Amasty_Mostviewed - 全量重置本地运行时文件
依赖补全、模块确认启用后,执行以下命令重置生成文件、缓存,避免旧的编译缓存干扰类加载:rm -rf generated/* var/cache/* var/page_cache/* var/view_preprocessed/* pub/static/* php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f php bin/magento cache:flush - 清理残留无效配置
如果以上操作完成后仍报错,说明数据库中存在该模块残留的Widget配置(多为本地之前测试卸载模块时未清理干净导致),直接在数据库widget表、cms_block表、cms_page表、layout_update表中搜索Amasty\Mostviewed\Block\Widget\Wrapper字符串,删除对应无效配置即可。
注意:每次导入生产数据库后必须重新执行一次
php bin/magento setup:upgrade,确保本地代码版本和数据库记录的模块版本一致,避免出现类加载、表结构不匹配类问题。
内容的提问来源于stack exchange,提问作者dreid
相关产品推荐
相关产品推荐

