I have added custom product option value to below interface ProductCustomOptionValuesInterface.php and Value.php model file.

File path: magento2/vendor/magento/module-catalog/Api/Data/ProductCustomOptionValuesInterface.php

File path: magento2/vendor/magento/module-catalog/Model/Product/Option/Value.php

But how to override above vendor file code to custom module.

Any help would be appreciated. Thanks!

  • which method do you want to override in value.php? I think you can use plugin or preferences to override value.php.
    – Nits
    Oct 23 '19 at 4:58
  • I need to add my custom new methods in ProductCustomOptionValuesInterface.php and Value.php Oct 23 '19 at 5:01
  • In this case, I would suggest to override only value.php file using preferences and add your custom function because Magento does not allow you to override interface.
    – Nits
    Oct 23 '19 at 6:48
  • After override only value.php how can add custom get set method in interface ? Oct 23 '19 at 6:50
  • @Nits Can you give me example for same. Interface and Model file ? Oct 23 '19 at 6:54

Magento 2 does not allow us to override the interfaces.

You can use Extension attributes for these things you can get help from online docs how to create Extension attributes in Magento 2 for interfaces.


You can achieve this by creating the Extension attributes.

Refer to this link: https://www.zynovo.com/blog/magento-2-extension-attributes/


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.