我尝试过在我的自定义模块中从_processAttributeOptions()中重写Magento\Eav\Model\ResourceModel\Entity\Attribute方法。但该函数不覆盖。这是我的代码:
Namespace\Module_Name\etc\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\Eav\Model\ResourceModel\Entity\Attribute" type="Namespace\Module_Name\Model\ResourceModel\Entity\Attribute" />
</config>Namespace\Module_Name\Model\ResourceModel\Entity\Attribute
<?php
namespace Namespace\Module_Name\Model\ResourceModel\Entity;
class Attribute extends \Magento\Eav\Model\ResourceModel\Entity\Attribute
{
protected function _processAttributeOptions($object, $option)
{
//here is my custom code with core
}
}请帮助我在Magento2.2中重写此方法。
发布于 2017-12-29 11:40:07
如果在小写中输入名称空间和模块名称,那么尝试用CamelCase替换它,比如用Namespace\Module替换namespace\module_name,并重命名文件夹。
https://stackoverflow.com/questions/48020905
复制相似问题