How to use extension attribute in magento 2

Extension attributes are configured in a module’s etc/extension_ attributes.xml file. Extension attributes can be scalar values or objects. These attributes are compiled into an Extension class and interface.

Add Custom Attribute in getData of Eav Collection magento 2

If you need to add a custom attribute to add in collection getData array. you need to add it in filter of addAttributeToFilter. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productCollection = $objectManager->create(‘Magento\Product\Model\Product\ResourceModel\CollectionFactory’)->create(); $productCollection->create()->addAttributeToFilter(‘custom_attr’, …