我写了一个简单的模块来覆盖这个核心的Model类,但是在前端它显示了这个错误信息:
“致命错误:未捕获TypeError:参数3传递给Magento \ Quote \ Model \ Quote \ ShippingAssignment \ ShippingProcessor :: __ construct()必须是Magento \ Quote \ Model \ ShippingMethodManagement的实例,shipping \ module \ Model \ ShippingMethodManagement \的实例拦截器......“
这是我的'di.xml'文件内容:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Quote\Model\ShippingMethodManagement" type="shipping\module\Model\ShippingMethodManagement" />
</config>
你需要做的事: -
php bin/magento s:up
并清理缓存
确保完全权限后,您需要运行以下命令:
chmod -R 777 var generated
php bin/magento setup:di:compile
php bin/magento cache:flush
如果错误仍然存在,请通过以下命令检查您是否处于开发人员模式:
php bin/magento deploy:mode:show
在开发者模式下设置:
php bin/magento deploy:mode:set developer
设置为开发人员模式后,删除var和生成的文件夹,
rm -rf var generated
然后刷新缓存:
php bin/magento cache:flush
chmod -R 777 var generated
使用下面给出的文件的核心路径扩展您的类。
在** shipping \ module \ Model **
class ShippingMethodManagement extends
Magento\Quote\Model\ShippingMethodManagement
{
//You can write your custom functionality here
}
不要忘记在更改后运行以下命令。
chmod -R 777 var generated
php bin/magento setup:di:compile
php bin/magento cache:flush