I have tried with preference to override interface as below in di.xml file
<preference for="Custom\Module\Api\Data\AccountInterface" type="Override\Module\Api\Data\AccountInterface" />
<preference for="Custom\Module\Model\Account" type="Override\Module\Model\Account" />
And My Interface file is like as below
Override\Module\Api\Data\AccountInterface.php
<?php
namespace Override\Module\Api\Data;
interface AccountInterface extends \Custom\Module\Api\Data\AccountInterface {
const AFFILIATE_ID = 'custom_id';
/**
* @return string|null
*/
public function getCustomId();
/**
* @param string $custom_id
*
* @return \Custom\Module\Api\Data\AccountInterface
*/
public function setCustomId($custom_id);
}
Override Model File with new method Logic as below
Override\Module\Model\Account.php
<?php
namespace Override\Module\Model;
use Custom\Module\Api\Data\AccountInterface;
use Magento\Framework\Model\Context;
use Magento\Framework\Model\ResourceModel\AbstractResource;
class Account extends \Custom\Module\Model\Account {
/**
* {@inheritdoc}
*/
public function getCustomId() {
return $this->_getData('custom_id');
}
/**
* {@inheritdoc}
*/
public function setCustomId($customId) {
$this->setData('custom_id', $customId);
return $this;
}
}
But it's not save the value of custom_id using setter and getter methods...
If use same setter and getter method and Model logic in Custom_Module directly then it's working fine.
Any solution of add custom method in Interface ?
note :- extension_attribute method is not available inside Custom\Module\Api\Data\AccountInterface so how we can use it ?