I was going to create a plugin so that I could extend Magento\Eav\Model\ResourceModel\Entity\Attribute::_processAttributeOptions(). However, because this method is protected, I am unable to do so.

I've added a column to the table eav_attribute_option_value called api_attribute_id and I need it to be updated when _saveOptions() triggers _processAttributeOptions().

Is the only way for me to rewrite this method for me to use <preference> and provide a class that extends it?


There is nothing wrong with overriding a protected method, you just cannot override a private method function.

Your purpose to write the addon value to new column of table eav_attribute_option_value so check the logic from

Magento\Eav\Model\ResourceModel\Entity\Attribute::_updateAttributeOptionValues($optionId, $values)

where data was insert to.

  • Right, we're talking about the same method but the plugin feature does not work on nonpublic methods. I am asking if implementing <prefer> in di.xml is the next best option. Thanks! – TylersSN Jan 15 at 4:26

you can override protected function by <preference>

here you can see how overriding protected methods link

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.