I have added an extension attribute by creating extension_attributes.xml file in etc. Its content is:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="Magento\Quote\Api\Data\AddressInterface">
<attribute code="custom_field" type="string" />
</extension_attributes>
</config>
Now when I try to get extension attribute in model I use following code:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$address = $objectManager->get('\Magento\Quote\Api\Data\AddressInterface');
echo $address->getExtensionAttributes()->getCustomField();
But the problem is $address->getExtensionAttributes()
return NULL. What am I doing wrong here?