php - 如何覆盖 Magento 2 的 \lib 文件夹中的 PHP 类?
问题描述
我想覆盖 lib 文件夹中的 PHP 文件。例如,我想用我自己的 PHP 类MyProject/application/Lorem/Customweb/Model/Processor覆盖MyProject/application/lib/internal/Customweb/Computop/Processor/Payolution/ Processor 。推荐的方法是使用类首选项。我创建了一个模块、一个 di.xml 和 PHP 替换文件。di.xml 找到了我自己的类,但没有找到它应该替换的类:
应用程序/app/code/Lorem/Customweb/etc/di.xml
<?xml version="1.0" encoding="utf-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Customweb\Computop\Processor\Payolution\Processor" type="Lorem\Customweb\Model\Processor" />
</config>
我多次检查拼写,所有路径都是正确的。我究竟做错了什么?
解决方案
推荐阅读
- ruby-on-rails - `a ||= b` 和 `a = b if a.nil 之间的区别?
- android - 我的平板电脑中的 ConstraintLayout 非常慢
- c++ - Redhat Linux - 未找到 SO 文件
- android - 是否有任何 API 可以检查 WiFi 是否已连接到 Internet?
- ios - Havok Project Anarchy 游戏引擎重复符号与 Google Analytics 库
- python - 在 .py 文件中使用 .py 文件
- php - 从 Nusoap 返回数组(未定义索引)
- mysql - 在存储过程 MYSQL 中创建临时表
- java - 如何将改造客户端从 Kotlin 转换为 Java 保留单例?
- templates - 在花括号内匹配 jq var