Skip to main content
5 of 10
added 163 characters in body
Rakesh Jesadiya
  • 42.4k
  • 19
  • 132
  • 184

Magento 2 - How to override Api interface method in our custom module

I am trying to override Magento\Eav\Api\Data\AttributeOptionInterface in my custom module. I want to add one new option to existing interface.

The idea behind is, As of now we can only pass defined options data in attribute options REST API

See below API request format for more clarity.

Api

Url = http://test.com/index.php/rest/V1/products/attributes/manufacturer/options/
Api Methodd - Post
Api body - {
  "option": {
    "label": "test",
    "is_default": "true",
  }
}

As of now its passing 3 parameters as value, I want to add my custom 4th parameters Ex - Slider.

So parameters should be

{
  "option": {
    "label": "test",
    "is_default": "true",
    "slider":"test1"
  }
}

I have tried to override interface and its method but its giving property setter not defined

Error Message

"message": "Property \"Slider\" does not have corresponding setter in class \"Magento\\Eav\\Api\\Data\\AttributeOptionInterface\"."

So here my question is how can I override API interface and pass my custom or add my option in existing parameters.

Hope it makes sense, your help will be appreciated.

Rakesh Jesadiya
  • 42.4k
  • 19
  • 132
  • 184