How to get the custom order attributes in default order Api response in magento 2.3 The Next CEO of Stack OverflowHow can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento2 How to get Custom order attributes value in response in rest api v1Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom Optionsget invoice item using order_item_id in magento 2How to get last order id in Magento 2.3?Magento 2.3 REST API Json response format issue
How to invert MapIndexed on a ragged structure? How to construct a tree from rules?
If/When UK leaves the EU, can a future goverment conduct a referendum to join the EU?
What exact does MIB represent in SNMP? How is it different from OID?
Are there any unintended negative consequences to allowing PCs to gain multiple levels at once in a short milestone-XP game?
What flight has the highest ratio of time difference to flight time?
Written every which way
Multiple labels for a single equation
Is it my responsibility to learn a new technology in my own time my employer wants to implement?
What connection does MS Office have to Netscape Navigator?
Is there a difference between "Fahrstuhl" and "Aufzug"
Which kind of appliances can one connect to electric sockets located in a airplane's toilet?
Why does standard notation not preserve intervals (visually)
Are there any limitations on attacking while grappling?
What happens if you roll doubles 3 times then land on "Go to jail?"
To not tell, not take, and not want
What does convergence in distribution "in the Gromov–Hausdorff" sense mean?
Interfacing a button to MCU (and PC) with 50m long cable
Why has the US not been more assertive in confronting Russia in recent years?
Several mode to write the symbol of a vector
Why does the UK parliament need a vote on the political declaration?
How to safely derail a train during transit?
Should I tutor a student who I know has cheated on their homework?
What benefits would be gained by using human laborers instead of drones in deep sea mining?
Won the lottery - how do I keep the money?
How to get the custom order attributes in default order Api response in magento 2.3
The Next CEO of Stack OverflowHow can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento2 How to get Custom order attributes value in response in rest api v1Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom Optionsget invoice item using order_item_id in magento 2How to get last order id in Magento 2.3?Magento 2.3 REST API Json response format issue
I have created a new custom order attribute named delivery_date and shown the same in sales order grid but i am not getting the custom attribute in my order Api response.
The error I am getting is Fatal error: Uncaught Error: Call to undefined method
MagentoSalesApiDataOrderExtension::setTipAndTrickAttribute()
Please help.
app/code/Amos/CustomOrder/etc/di.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<virtualType name="MagentoSalesModelResourceModelOrderGrid" type="MagentoSalesModelResourceModelGrid">
<arguments>
<argument name="columns" xsi:type="array">
<item name="delivery_date" xsi:type="string">sales_order.delivery_date</item>
<item name="no_of_days" xsi:type="string">sales_order.no_of_days</item>
<item name="no_of_crew" xsi:type="string">sales_order.no_of_crew</item>
</argument>
</arguments>
</virtualType>
</config>
app/code/Amos/CustomOrder/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_load_after">
<observer name="sales_order_load_delivery_date" instance="MagestoreTipAndTrickObserverSalesOrderLoadAfter" />
</event>
</config>
Amos/CustomOrder/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="MagentoSalesApiDataOrderInterface">
<attribute code="delivery_date" type="string" />
</extension_attributes>
</config>
Amos/CustomOrder/Observer/Sales/OrderLoadAfter.php
<?php
namespace AmosCustomOrderObserverSales;
use MagentoFrameworkEventObserverInterface;
class OrderLoadAfter implements ObserverInterface
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getOrder();
$extensionAttributes = $order->getExtensionAttributes();
if ($extensionAttributes === null)
$extensionAttributes = $this->getOrderExtensionDependency();
$attr = $order->getData('delivery_date');
$extensionAttributes->setTipAndTrickAttribute($attr);
$order->setExtensionAttributes($extensionAttributes);
private function getOrderExtensionDependency()
$orderExtension = MagentoFrameworkAppObjectManager::getInstance()->get(
'MagentoSalesApiDataOrderExtension'
);
return $orderExtension;
magento2 magento2.3 magento-community
New contributor
add a comment |
I have created a new custom order attribute named delivery_date and shown the same in sales order grid but i am not getting the custom attribute in my order Api response.
The error I am getting is Fatal error: Uncaught Error: Call to undefined method
MagentoSalesApiDataOrderExtension::setTipAndTrickAttribute()
Please help.
app/code/Amos/CustomOrder/etc/di.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<virtualType name="MagentoSalesModelResourceModelOrderGrid" type="MagentoSalesModelResourceModelGrid">
<arguments>
<argument name="columns" xsi:type="array">
<item name="delivery_date" xsi:type="string">sales_order.delivery_date</item>
<item name="no_of_days" xsi:type="string">sales_order.no_of_days</item>
<item name="no_of_crew" xsi:type="string">sales_order.no_of_crew</item>
</argument>
</arguments>
</virtualType>
</config>
app/code/Amos/CustomOrder/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_load_after">
<observer name="sales_order_load_delivery_date" instance="MagestoreTipAndTrickObserverSalesOrderLoadAfter" />
</event>
</config>
Amos/CustomOrder/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="MagentoSalesApiDataOrderInterface">
<attribute code="delivery_date" type="string" />
</extension_attributes>
</config>
Amos/CustomOrder/Observer/Sales/OrderLoadAfter.php
<?php
namespace AmosCustomOrderObserverSales;
use MagentoFrameworkEventObserverInterface;
class OrderLoadAfter implements ObserverInterface
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getOrder();
$extensionAttributes = $order->getExtensionAttributes();
if ($extensionAttributes === null)
$extensionAttributes = $this->getOrderExtensionDependency();
$attr = $order->getData('delivery_date');
$extensionAttributes->setTipAndTrickAttribute($attr);
$order->setExtensionAttributes($extensionAttributes);
private function getOrderExtensionDependency()
$orderExtension = MagentoFrameworkAppObjectManager::getInstance()->get(
'MagentoSalesApiDataOrderExtension'
);
return $orderExtension;
magento2 magento2.3 magento-community
New contributor
Hi Meetali, welcome to Magento SE, Please clear generated/ folder or try with di:compile
– Ramkishan Suthar
2 days ago
1
One more thing you are calling wrong method it should be setDeliveryDate() not setTipAndTrickAttribute()
– Ramkishan Suthar
2 days ago
Hi Ramkishan, thank you for the response. Now the error of wrong method is resolved but still i did'nt got the delivery_date attribute in my Api response.
– Meetali Gupta
yesterday
I guess, setting extension attribute value in observer won't work you should try plugin instead of observer.
– Ramkishan Suthar
yesterday
add a comment |
I have created a new custom order attribute named delivery_date and shown the same in sales order grid but i am not getting the custom attribute in my order Api response.
The error I am getting is Fatal error: Uncaught Error: Call to undefined method
MagentoSalesApiDataOrderExtension::setTipAndTrickAttribute()
Please help.
app/code/Amos/CustomOrder/etc/di.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<virtualType name="MagentoSalesModelResourceModelOrderGrid" type="MagentoSalesModelResourceModelGrid">
<arguments>
<argument name="columns" xsi:type="array">
<item name="delivery_date" xsi:type="string">sales_order.delivery_date</item>
<item name="no_of_days" xsi:type="string">sales_order.no_of_days</item>
<item name="no_of_crew" xsi:type="string">sales_order.no_of_crew</item>
</argument>
</arguments>
</virtualType>
</config>
app/code/Amos/CustomOrder/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_load_after">
<observer name="sales_order_load_delivery_date" instance="MagestoreTipAndTrickObserverSalesOrderLoadAfter" />
</event>
</config>
Amos/CustomOrder/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="MagentoSalesApiDataOrderInterface">
<attribute code="delivery_date" type="string" />
</extension_attributes>
</config>
Amos/CustomOrder/Observer/Sales/OrderLoadAfter.php
<?php
namespace AmosCustomOrderObserverSales;
use MagentoFrameworkEventObserverInterface;
class OrderLoadAfter implements ObserverInterface
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getOrder();
$extensionAttributes = $order->getExtensionAttributes();
if ($extensionAttributes === null)
$extensionAttributes = $this->getOrderExtensionDependency();
$attr = $order->getData('delivery_date');
$extensionAttributes->setTipAndTrickAttribute($attr);
$order->setExtensionAttributes($extensionAttributes);
private function getOrderExtensionDependency()
$orderExtension = MagentoFrameworkAppObjectManager::getInstance()->get(
'MagentoSalesApiDataOrderExtension'
);
return $orderExtension;
magento2 magento2.3 magento-community
New contributor
I have created a new custom order attribute named delivery_date and shown the same in sales order grid but i am not getting the custom attribute in my order Api response.
The error I am getting is Fatal error: Uncaught Error: Call to undefined method
MagentoSalesApiDataOrderExtension::setTipAndTrickAttribute()
Please help.
app/code/Amos/CustomOrder/etc/di.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<virtualType name="MagentoSalesModelResourceModelOrderGrid" type="MagentoSalesModelResourceModelGrid">
<arguments>
<argument name="columns" xsi:type="array">
<item name="delivery_date" xsi:type="string">sales_order.delivery_date</item>
<item name="no_of_days" xsi:type="string">sales_order.no_of_days</item>
<item name="no_of_crew" xsi:type="string">sales_order.no_of_crew</item>
</argument>
</arguments>
</virtualType>
</config>
app/code/Amos/CustomOrder/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_load_after">
<observer name="sales_order_load_delivery_date" instance="MagestoreTipAndTrickObserverSalesOrderLoadAfter" />
</event>
</config>
Amos/CustomOrder/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="MagentoSalesApiDataOrderInterface">
<attribute code="delivery_date" type="string" />
</extension_attributes>
</config>
Amos/CustomOrder/Observer/Sales/OrderLoadAfter.php
<?php
namespace AmosCustomOrderObserverSales;
use MagentoFrameworkEventObserverInterface;
class OrderLoadAfter implements ObserverInterface
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getOrder();
$extensionAttributes = $order->getExtensionAttributes();
if ($extensionAttributes === null)
$extensionAttributes = $this->getOrderExtensionDependency();
$attr = $order->getData('delivery_date');
$extensionAttributes->setTipAndTrickAttribute($attr);
$order->setExtensionAttributes($extensionAttributes);
private function getOrderExtensionDependency()
$orderExtension = MagentoFrameworkAppObjectManager::getInstance()->get(
'MagentoSalesApiDataOrderExtension'
);
return $orderExtension;
magento2 magento2.3 magento-community
magento2 magento2.3 magento-community
New contributor
New contributor
edited 2 days ago
ABHISHEK TRIPATHI
2,0081727
2,0081727
New contributor
asked 2 days ago
Meetali GuptaMeetali Gupta
111
111
New contributor
New contributor
Hi Meetali, welcome to Magento SE, Please clear generated/ folder or try with di:compile
– Ramkishan Suthar
2 days ago
1
One more thing you are calling wrong method it should be setDeliveryDate() not setTipAndTrickAttribute()
– Ramkishan Suthar
2 days ago
Hi Ramkishan, thank you for the response. Now the error of wrong method is resolved but still i did'nt got the delivery_date attribute in my Api response.
– Meetali Gupta
yesterday
I guess, setting extension attribute value in observer won't work you should try plugin instead of observer.
– Ramkishan Suthar
yesterday
add a comment |
Hi Meetali, welcome to Magento SE, Please clear generated/ folder or try with di:compile
– Ramkishan Suthar
2 days ago
1
One more thing you are calling wrong method it should be setDeliveryDate() not setTipAndTrickAttribute()
– Ramkishan Suthar
2 days ago
Hi Ramkishan, thank you for the response. Now the error of wrong method is resolved but still i did'nt got the delivery_date attribute in my Api response.
– Meetali Gupta
yesterday
I guess, setting extension attribute value in observer won't work you should try plugin instead of observer.
– Ramkishan Suthar
yesterday
Hi Meetali, welcome to Magento SE, Please clear generated/ folder or try with di:compile
– Ramkishan Suthar
2 days ago
Hi Meetali, welcome to Magento SE, Please clear generated/ folder or try with di:compile
– Ramkishan Suthar
2 days ago
1
1
One more thing you are calling wrong method it should be setDeliveryDate() not setTipAndTrickAttribute()
– Ramkishan Suthar
2 days ago
One more thing you are calling wrong method it should be setDeliveryDate() not setTipAndTrickAttribute()
– Ramkishan Suthar
2 days ago
Hi Ramkishan, thank you for the response. Now the error of wrong method is resolved but still i did'nt got the delivery_date attribute in my Api response.
– Meetali Gupta
yesterday
Hi Ramkishan, thank you for the response. Now the error of wrong method is resolved but still i did'nt got the delivery_date attribute in my Api response.
– Meetali Gupta
yesterday
I guess, setting extension attribute value in observer won't work you should try plugin instead of observer.
– Ramkishan Suthar
yesterday
I guess, setting extension attribute value in observer won't work you should try plugin instead of observer.
– Ramkishan Suthar
yesterday
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Meetali Gupta is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f267717%2fhow-to-get-the-custom-order-attributes-in-default-order-api-response-in-magento%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Meetali Gupta is a new contributor. Be nice, and check out our Code of Conduct.
Meetali Gupta is a new contributor. Be nice, and check out our Code of Conduct.
Meetali Gupta is a new contributor. Be nice, and check out our Code of Conduct.
Meetali Gupta is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f267717%2fhow-to-get-the-custom-order-attributes-in-default-order-api-response-in-magento%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hi Meetali, welcome to Magento SE, Please clear generated/ folder or try with di:compile
– Ramkishan Suthar
2 days ago
1
One more thing you are calling wrong method it should be setDeliveryDate() not setTipAndTrickAttribute()
– Ramkishan Suthar
2 days ago
Hi Ramkishan, thank you for the response. Now the error of wrong method is resolved but still i did'nt got the delivery_date attribute in my Api response.
– Meetali Gupta
yesterday
I guess, setting extension attribute value in observer won't work you should try plugin instead of observer.
– Ramkishan Suthar
yesterday