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.

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.