0

I need to override this interface

Magento\Catalog\Api\Data\CategoryTreeInterface

I need to add setIncludeInMenu & getIncludeInMenu but there are no extension attributes, how can I achieve this?

paj
  • 5,785
  • 5
  • 21
  • 43
Arjun
  • 3,576
  • 23
  • 59

1 Answers1

0

Seems the only core class that implements \Magento\Catalog\Api\Data\CategoryTreeInterface is \Magento\Catalog\Model\Category? This model has extension attributes as it also implements \Magento\Catalog\Api\Data\CategoryInterface. Can you maybe add extension attributes here?

If you've defined a custom class to override the implementation of CategoryTreeInterface (this can be done via di.xml class preference), you might just have to define getter/setter methods on the implementation class. Interfaces by definition cannot be amended with new methods.

Liam Toohey
  • 452
  • 3
  • 13
  • Hi. can you please add some code how to achieve this? – Arjun Feb 15 '22 at 12:08
  • Considering that the only core implementation of CategoryTreeInterface is \Magento\Catalog\Model\Category - which has accessible extension attributes, I'd advise you follow the core devdocs: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html – Liam Toohey Feb 16 '22 at 11:17
  • How can I do it without that – Arjun Feb 16 '22 at 11:23