0

I'm having a hard time wrapping my brain around how these extension attributes works. I sorta get how they work for an extension, but what I'm trying to do is extend a 3rd party extension's model to include a new database field that I've added to a table that the extension uses.

I have an extension that has the following in its 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\Quote\Api\Data\CartInterface">
 <attribute code="aw_ctq_quote" type="Aheadworks\Ctq\Api\Data\QuoteInterface">
 <join reference_table="aw_ctq_quote" reference_field="id" join_on_field="entity_id">
 <field>id</field>
 <field>customer_id</field>
 <field>name</field>
 <field>created_at</field>
 <field>last_updated_at</field>
 <field>status</field>
 <field>expiration_date</field>
 <field>cart</field>
 <field>store_id</field>
 <field>base_quote_total</field>
 <field>quote_total</field>
 <field>base_quote_total_negotiated</field>
 <field>quote_total_negotiated</field>
 </join>
 </attribute>
 </extension_attributes>
</config>

Like I said, I added a column to the the "aw_ctq_quote" table via an upgrade schema script in my custom module, and that added just fine. I have changed the PHTML template where this data gets entered by the backend user, and it does POST just fine. I'm trying to have the model update the data set now, but I have no idea how to tell Magento to also include this other field. I can't update the example XML because it's a composer extension.

How can I update the model to include this other field? I'm not sure how I can tell Magento to also include this other column. I started looking into extending interfaces but I'm not sure if I have to specify a new model or what exactly I need to be looking for. Every search I do turns up how to make your own interface with new extension attributes but no mention of extending/overriding an existing one.

Any pointers here would be fantastic. Thanks so much

asked Mar 11, 2021 at 23:19
1
  • Any success solving this problem? Commented Apr 26, 2022 at 15:42

1 Answer 1

0

you can use an after plugin on the method (about your entity, for example \Magento\Sales\Model\Order) and getting the $order->getExtensionAttributes(). After this, you can your extension attributes and save order.

answered Mar 12, 2021 at 11:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.