3

For example, I've added an extension attribute to order

<!-- etc/extension_attributes.xml -->   
<?xml version="1.0"?>   
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">   
    <extension_attributes for="Magento\Sales\Api\Data\OrderInterface">  
    <attribute code="tigren_attribute" type="Tigren\Example\Api\Data\TigrenAttributeInterface" />
    </extension_attributes> 
</config>

after an order is saved , where can i find the ext attr in Db?

1

2 Answers 2

5

Currently, extension attributes are only about Web API. You need to save extension attributes manually using plugins on appropriate services.

If you want to save Extension Attributes to DB than you need to add column.

Regarding DB : It stores to the relative table of entity.

For Example:

<extension_attributes for="Magento\SalesRule\Api\Data\RuleInterface">
    <attribute code="start_date" type="string" />
    <attribute code="end_date" type="string" />
    <attribute code="brands" type="string" />
</extension_attributes>

Above code is for Sales Rule Extension Attributes, So it will store to RuleInterface related table that is salesrule.

-1

I created a new Table, now I want to get a column of this table i can do that? I tried with the following code but it's not working as per the expectation.

 $customerData->setCustomAttribute('computer_brand', $computerBrand)
                ->setCustomAttribute('computer_model', $computerModel)
                ->setCustomAttribute('entity_id', $customerId);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.