3

I have tried to override _processAttributeOptions() method from Magento\Eav\Model\ResourceModel\Entity\Attribute in my custom module. But the function does not override. Here is my code:

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
    }
}

Please help me to override this method in Magento 2.2.

Ramanathan
  • 309
  • 3
  • 12

1 Answers1

0

It does not override because _processAttributeOptions is called from \Magento\Catalog\Model\ResourceModel\Attribute which extends \Magento\Eav\Model\ResourceModel\Entity\Attribute. So to override \Magento\Eav\Model\ResourceModel\Entity\Attribute you should put the preference for the catalog model.

Piyush
  • 5,893
  • 9
  • 34
  • 64