I have created one custom field in Magento 2 payment table through install schema and want to add getter and setter to the Magento\Quote\Api\Data\PaymentInterface to set and add data.
extension_attributes.xml
<extension_attributes for="Magento\Quote\Api\Data\PaymentInterface">
<attribute code="policy_no" type="string"/>
</extension_attributes>
When i want to retrieve that value through below code i am getting
null.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$paymentInformation = $objectManager->create('Magento\Quote\Api\Data\PaymentInterface');
$extAttributes = $paymentInformation->getExtensionAttributes();
var_dump($extAttributes);exit;
Best Answer
You have to setExtensionAttributes manually.
Example:
CustomerRepositoryInterfacePlugin.php
di.xml