Magento 2 Set order attribute via order create apiMagento search rest apiMagento 2 : Social Login via Rest ApiMagento 2 Rest API - how do I add values to dropdown product attributeAdding extension attributes to Order API Endpointget order by string/value in product_options arrayIs Magento 2 REST API CSRF-proof?Problem adding attribute options to configurable product via REST ApiMagento 2: Is it possible to create Product attributes sets and their options programmatically but not during the installMagento 2: Get Order Info From InvoiceCreate customer with default addresses via API
Heinlein story regarding suspended animation and reading newspapers?
A wiild aanimal, a cardinal direction, or a place by the water
Applying for FHA mortgage when living together but only one will be on the mortgage, no savings
Why are Star Wars Rebel Alliance ships named after letters from the Latin alphabet?
Define tcolorbox in math mode
Why is “deal 6 damage” a legit phrase?
On the expression " sun-down"
Is there a general term for the items in a directory?
Plotting Chebyshev polynomials using PolarPlot and FilledCurve
Has J.J.Jameson ever found out that Peter Parker is Spider-Man?
What is the reason behind water not falling from a bucket at the top of loop?
How to power down external drive safely
Does the problem of P vs NP come under the category of Operational Research?
How do people drown while wearing a life jacket?
How did Biff return to 2015 from 1955 without a lightning strike?
How to structure presentation to avoid getting questions that will be answered later in the presentation?
δόλος = deceit in John 1:47
Deflecting lasers with lightsabers
Word for pulling a punch in karate
UX writing: When to use "we"?
Return last number in sub-sequences in a list of integers
Where do I keep track of sorcery points on a character sheet?
Any information about the photo with Army Uniforms
How were x-ray diffraction patterns deciphered before computers?
Magento 2 Set order attribute via order create api
Magento search rest apiMagento 2 : Social Login via Rest ApiMagento 2 Rest API - how do I add values to dropdown product attributeAdding extension attributes to Order API Endpointget order by string/value in product_options arrayIs Magento 2 REST API CSRF-proof?Problem adding attribute options to configurable product via REST ApiMagento 2: Is it possible to create Product attributes sets and their options programmatically but not during the installMagento 2: Get Order Info From InvoiceCreate customer with default addresses via API
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've created a couple of order attributes using the method described here (https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) in order to save some data that is passed into Magento 2 via our legacy application.
Is it possible to pass these values over when creating an order via the API? or is there a better way to achieve the same result? I'm using Magento 2.3 if that has any impact.
magento2 attributes orders rest-api magento2.3.1
add a comment |
I've created a couple of order attributes using the method described here (https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) in order to save some data that is passed into Magento 2 via our legacy application.
Is it possible to pass these values over when creating an order via the API? or is there a better way to achieve the same result? I'm using Magento 2.3 if that has any impact.
magento2 attributes orders rest-api magento2.3.1
add a comment |
I've created a couple of order attributes using the method described here (https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) in order to save some data that is passed into Magento 2 via our legacy application.
Is it possible to pass these values over when creating an order via the API? or is there a better way to achieve the same result? I'm using Magento 2.3 if that has any impact.
magento2 attributes orders rest-api magento2.3.1
I've created a couple of order attributes using the method described here (https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) in order to save some data that is passed into Magento 2 via our legacy application.
Is it possible to pass these values over when creating an order via the API? or is there a better way to achieve the same result? I'm using Magento 2.3 if that has any impact.
magento2 attributes orders rest-api magento2.3.1
magento2 attributes orders rest-api magento2.3.1
asked Jul 24 at 10:08
MatthewMatthew
1134 bronze badges
1134 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
First read this below articles:
- https://store.fooman.co.nz/blog/an-introduction-to-extension-attributes.html
- https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html
If you want to add a field them you need to use extension_atttibutes
Extension attribute gives the facility to add a new field to existing API point.
The fields which you have created using https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) to be used as an extension attribute for data MagentoSalesApiDataOrderInterface
.
So, create etc/extension_attributes.xml
at your module folder
<?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="is_important" type="string" /> <!-- type defined as string -->
</extension_attributes>
</config>
Save field to order table
And as you have created the column to an existing order table, So save the create before plugin on MagentoSalesApiOrderRepositoryInterface::save()
.
<?php
namespace YereoneNewOrderAttributePlugin;
use MagentoFrameworkExceptionCouldNotSaveException;
class OrderSave
...
public function beforeSave(
MagentoSalesApiOrderRepositoryInterface $subject,
MagentoSalesApiDataOrderInterface $resultOrder
)
$extensionAttributes = $resultOrder->getExtensionAttributes();
if (null !== $extensionAttributes)
$extensionAttributes->getIsImportant()->getValue();
$resultOrder->setIsImportant( $extensionAttributes->getIsImportant()->getValue());
return $resultOrder;
Seems like a sensible approach, my only comment would be if I save data as an extension attribute AND then save it to the order table fields I've added am I not just duplicating data? Is there any way to show extension attributes in the sales order grid?
– Matthew
Jul 24 at 10:57
add a comment |
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
);
);
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%2f283138%2fmagento-2-set-order-attribute-via-order-create-api%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First read this below articles:
- https://store.fooman.co.nz/blog/an-introduction-to-extension-attributes.html
- https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html
If you want to add a field them you need to use extension_atttibutes
Extension attribute gives the facility to add a new field to existing API point.
The fields which you have created using https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) to be used as an extension attribute for data MagentoSalesApiDataOrderInterface
.
So, create etc/extension_attributes.xml
at your module folder
<?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="is_important" type="string" /> <!-- type defined as string -->
</extension_attributes>
</config>
Save field to order table
And as you have created the column to an existing order table, So save the create before plugin on MagentoSalesApiOrderRepositoryInterface::save()
.
<?php
namespace YereoneNewOrderAttributePlugin;
use MagentoFrameworkExceptionCouldNotSaveException;
class OrderSave
...
public function beforeSave(
MagentoSalesApiOrderRepositoryInterface $subject,
MagentoSalesApiDataOrderInterface $resultOrder
)
$extensionAttributes = $resultOrder->getExtensionAttributes();
if (null !== $extensionAttributes)
$extensionAttributes->getIsImportant()->getValue();
$resultOrder->setIsImportant( $extensionAttributes->getIsImportant()->getValue());
return $resultOrder;
Seems like a sensible approach, my only comment would be if I save data as an extension attribute AND then save it to the order table fields I've added am I not just duplicating data? Is there any way to show extension attributes in the sales order grid?
– Matthew
Jul 24 at 10:57
add a comment |
First read this below articles:
- https://store.fooman.co.nz/blog/an-introduction-to-extension-attributes.html
- https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html
If you want to add a field them you need to use extension_atttibutes
Extension attribute gives the facility to add a new field to existing API point.
The fields which you have created using https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) to be used as an extension attribute for data MagentoSalesApiDataOrderInterface
.
So, create etc/extension_attributes.xml
at your module folder
<?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="is_important" type="string" /> <!-- type defined as string -->
</extension_attributes>
</config>
Save field to order table
And as you have created the column to an existing order table, So save the create before plugin on MagentoSalesApiOrderRepositoryInterface::save()
.
<?php
namespace YereoneNewOrderAttributePlugin;
use MagentoFrameworkExceptionCouldNotSaveException;
class OrderSave
...
public function beforeSave(
MagentoSalesApiOrderRepositoryInterface $subject,
MagentoSalesApiDataOrderInterface $resultOrder
)
$extensionAttributes = $resultOrder->getExtensionAttributes();
if (null !== $extensionAttributes)
$extensionAttributes->getIsImportant()->getValue();
$resultOrder->setIsImportant( $extensionAttributes->getIsImportant()->getValue());
return $resultOrder;
Seems like a sensible approach, my only comment would be if I save data as an extension attribute AND then save it to the order table fields I've added am I not just duplicating data? Is there any way to show extension attributes in the sales order grid?
– Matthew
Jul 24 at 10:57
add a comment |
First read this below articles:
- https://store.fooman.co.nz/blog/an-introduction-to-extension-attributes.html
- https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html
If you want to add a field them you need to use extension_atttibutes
Extension attribute gives the facility to add a new field to existing API point.
The fields which you have created using https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) to be used as an extension attribute for data MagentoSalesApiDataOrderInterface
.
So, create etc/extension_attributes.xml
at your module folder
<?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="is_important" type="string" /> <!-- type defined as string -->
</extension_attributes>
</config>
Save field to order table
And as you have created the column to an existing order table, So save the create before plugin on MagentoSalesApiOrderRepositoryInterface::save()
.
<?php
namespace YereoneNewOrderAttributePlugin;
use MagentoFrameworkExceptionCouldNotSaveException;
class OrderSave
...
public function beforeSave(
MagentoSalesApiOrderRepositoryInterface $subject,
MagentoSalesApiDataOrderInterface $resultOrder
)
$extensionAttributes = $resultOrder->getExtensionAttributes();
if (null !== $extensionAttributes)
$extensionAttributes->getIsImportant()->getValue();
$resultOrder->setIsImportant( $extensionAttributes->getIsImportant()->getValue());
return $resultOrder;
First read this below articles:
- https://store.fooman.co.nz/blog/an-introduction-to-extension-attributes.html
- https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html
If you want to add a field them you need to use extension_atttibutes
Extension attribute gives the facility to add a new field to existing API point.
The fields which you have created using https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) to be used as an extension attribute for data MagentoSalesApiDataOrderInterface
.
So, create etc/extension_attributes.xml
at your module folder
<?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="is_important" type="string" /> <!-- type defined as string -->
</extension_attributes>
</config>
Save field to order table
And as you have created the column to an existing order table, So save the create before plugin on MagentoSalesApiOrderRepositoryInterface::save()
.
<?php
namespace YereoneNewOrderAttributePlugin;
use MagentoFrameworkExceptionCouldNotSaveException;
class OrderSave
...
public function beforeSave(
MagentoSalesApiOrderRepositoryInterface $subject,
MagentoSalesApiDataOrderInterface $resultOrder
)
$extensionAttributes = $resultOrder->getExtensionAttributes();
if (null !== $extensionAttributes)
$extensionAttributes->getIsImportant()->getValue();
$resultOrder->setIsImportant( $extensionAttributes->getIsImportant()->getValue());
return $resultOrder;
edited Jul 30 at 11:25
MageCoder
559 bronze badges
559 bronze badges
answered Jul 24 at 10:29
Amit Bera♦Amit Bera
62.7k16 gold badges84 silver badges183 bronze badges
62.7k16 gold badges84 silver badges183 bronze badges
Seems like a sensible approach, my only comment would be if I save data as an extension attribute AND then save it to the order table fields I've added am I not just duplicating data? Is there any way to show extension attributes in the sales order grid?
– Matthew
Jul 24 at 10:57
add a comment |
Seems like a sensible approach, my only comment would be if I save data as an extension attribute AND then save it to the order table fields I've added am I not just duplicating data? Is there any way to show extension attributes in the sales order grid?
– Matthew
Jul 24 at 10:57
Seems like a sensible approach, my only comment would be if I save data as an extension attribute AND then save it to the order table fields I've added am I not just duplicating data? Is there any way to show extension attributes in the sales order grid?
– Matthew
Jul 24 at 10:57
Seems like a sensible approach, my only comment would be if I save data as an extension attribute AND then save it to the order table fields I've added am I not just duplicating data? Is there any way to show extension attributes in the sales order grid?
– Matthew
Jul 24 at 10:57
add a comment |
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%2f283138%2fmagento-2-set-order-attribute-via-order-create-api%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