首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Magento2.2中重写Magento\Eav\Model\ResourceModel\Entity\Attribute类方法?

如何在Magento2.2中重写Magento\Eav\Model\ResourceModel\Entity\Attribute类方法?
EN

Stack Overflow用户
提问于 2017-12-29 10:11:52
回答 1查看 708关注 0票数 0

我尝试过在我的自定义模块中从_processAttributeOptions()中重写Magento\Eav\Model\ResourceModel\Entity\Attribute方法。但该函数不覆盖。这是我的代码:

Namespace\Module_Name\etc\di.xml

代码语言:javascript
复制
<?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

代码语言:javascript
复制
<?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中重写此方法。

EN

回答 1

Stack Overflow用户

发布于 2017-12-29 11:40:07

如果在小写中输入名称空间和模块名称,那么尝试用CamelCase替换它,比如用Namespace\Module替换namespace\module_name,并重命名文件夹。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48020905

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档