Magento 2 | Access custom order attribute
check if the column is created in sales_order
table
Now getting the values
$order->getMediabasebestellnummer();
Or
$order->getData('mediabasebestellnummer');
For adding the data
$order->setMediabasebestellnummer('test value')->save();
or
$order->setData('mediabasebestellnummer','test value')->save();
or
$data = array('mediabasebestellnummer'=>'test');
$order->setData($data)->save();`
Make sure you have file fieldset.xml
in your module to convert data from quote to order.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:DataObject/etc/fieldset.xsd">
<scope id="global">
<fieldset id="sales_convert_quote">
<field name="mediabasebestellnummer">
<aspect name="to_order" />
</field>
</fieldset>
</scope>
</config>