How do I query on an extension attribute through the API? The 2019 Stack Overflow Developer...
Why do some words that are not inflected have an umlaut?
Are there any other methods to apply to solving simultaneous equations?
"as much details as you can remember"
What is the motivation for a law requiring 2 parties to consent for recording a conversation
How to answer pointed "are you quitting" questioning when I don't want them to suspect
What to do when moving next to a bird sanctuary with a loosely-domesticated cat?
Does the shape of a die affect the probability of a number being rolled?
Why can Shazam fly?
Can you compress metal and what would be the consequences?
Resizing object distorts it (Illustrator CC 2018)
Is an up-to-date browser secure on an out-of-date OS?
Can a flute soloist sit?
Button changing it's text & action. Good or terrible?
Worn-tile Scrabble
What do hard-Brexiteers want with respect to the Irish border?
How are circuits which use complex ICs normally simulated?
Which Sci-Fi work first showed weapon of galactic-scale mass destruction?
If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?
How to obtain Confidence Intervals for a LASSO regression?
Have you ever entered Singapore using a different passport or name?
What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
Landlord wants to switch my lease to a "Land contract" to "get back at the city"
How to notate time signature switching consistently every measure
How do I query on an extension attribute through the API?
The 2019 Stack Overflow Developer Survey Results Are InFiltering product list by extension attributeMagento 2.1 Rest API - Adding to Extension Attributes for VI/Orders/?searchcriteriaMagento 2 - Save Extension Attribute afterSave() returns voidOrder item extension attributes are always last database entrySave extension attribute on sales_orderMagento 2 order REST Api append Custom AttributeMagento 2 REST - SKU to items on cart totals API response is not available, How to get SKU in response APIHow to get the extension attributes in shipping info and order/{id} APi magento2?API error when adding an extension attributeHow do I save a string extension attribute to the database
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I added an extension attribute to the Invoice class, and I want to be able to query the Invoice database data by my extension attribute.
My extension attribute (ExportedFlag) has these properties
entity_idThe primary key
invoice_idThe foreign key to the invoice table.
isExportedA string value.
When an invoice gets created, it will not have a corresponding row in my extension attribute table. I want to be able to query the database for a list of invoices that don't have a value for the extension attribute, using the API (and then insert the value for that extension attribute).
Here's the code that I have right now that adds the extension attribute to invoices.
public function afterGetList
(
MagentoSalesApiInvoiceRepositoryInterface $subject,
MagentoSalesModelResourceModelOrderInvoiceCollection $searchResult
) {
/** @var MagentoCatalogApiDataInvoiceInterface $invoice */
foreach ($searchResult as $invoice) {
$this->addExportedFlagToInvoice($invoice);
}
return $searchResult;
}
private function addExportedFlagToInvoice(MagentoSalesApiDataInvoiceInterface $invoice)
{
$extensionAttributes = $invoice->getExtensionAttributes();
if (empty($extensionAttributes)) {
$extensionAttributes = $this->invoiceExtensionFactory->create();
}
$exportedFlag = $this->exportedFlagProvider->getExportedFlag($invoice->getEntityId());
$extensionAttributes->setExportedFlag($exportedFlag);
$invoice->setExtensionAttributes($extensionAttributes);
$exportedFlag = $extensionAttributes->getExportedFlag();
$exportedFlag->setInvoiceId($invoice->getEntityId());
$this->entityManager->save($exportedFlag);
return $this;
}
The problem is that this code iterates through each invoice, and adds the extension attribute one-by-one. Furthermore, it retrieves all invoices, regardless of whether or not they have a value for the extension attribute (I don't want to retrieve values that have a row in the extension attributes table).
I want to be able to retrieve all invoices in a single query. Something like this
SELECT *
FROM sales_order_invoice
LEFT OUTER JOIN extensionAttribute
ON sales_order_invoice.entity_id = extensionAttribute.invoice_id
WHERE extensionAttribute.isExported IS NULL
How can I do this within Magento?
magento2 database extension-attributes
add a comment |
I added an extension attribute to the Invoice class, and I want to be able to query the Invoice database data by my extension attribute.
My extension attribute (ExportedFlag) has these properties
entity_idThe primary key
invoice_idThe foreign key to the invoice table.
isExportedA string value.
When an invoice gets created, it will not have a corresponding row in my extension attribute table. I want to be able to query the database for a list of invoices that don't have a value for the extension attribute, using the API (and then insert the value for that extension attribute).
Here's the code that I have right now that adds the extension attribute to invoices.
public function afterGetList
(
MagentoSalesApiInvoiceRepositoryInterface $subject,
MagentoSalesModelResourceModelOrderInvoiceCollection $searchResult
) {
/** @var MagentoCatalogApiDataInvoiceInterface $invoice */
foreach ($searchResult as $invoice) {
$this->addExportedFlagToInvoice($invoice);
}
return $searchResult;
}
private function addExportedFlagToInvoice(MagentoSalesApiDataInvoiceInterface $invoice)
{
$extensionAttributes = $invoice->getExtensionAttributes();
if (empty($extensionAttributes)) {
$extensionAttributes = $this->invoiceExtensionFactory->create();
}
$exportedFlag = $this->exportedFlagProvider->getExportedFlag($invoice->getEntityId());
$extensionAttributes->setExportedFlag($exportedFlag);
$invoice->setExtensionAttributes($extensionAttributes);
$exportedFlag = $extensionAttributes->getExportedFlag();
$exportedFlag->setInvoiceId($invoice->getEntityId());
$this->entityManager->save($exportedFlag);
return $this;
}
The problem is that this code iterates through each invoice, and adds the extension attribute one-by-one. Furthermore, it retrieves all invoices, regardless of whether or not they have a value for the extension attribute (I don't want to retrieve values that have a row in the extension attributes table).
I want to be able to retrieve all invoices in a single query. Something like this
SELECT *
FROM sales_order_invoice
LEFT OUTER JOIN extensionAttribute
ON sales_order_invoice.entity_id = extensionAttribute.invoice_id
WHERE extensionAttribute.isExported IS NULL
How can I do this within Magento?
magento2 database extension-attributes
add a comment |
I added an extension attribute to the Invoice class, and I want to be able to query the Invoice database data by my extension attribute.
My extension attribute (ExportedFlag) has these properties
entity_idThe primary key
invoice_idThe foreign key to the invoice table.
isExportedA string value.
When an invoice gets created, it will not have a corresponding row in my extension attribute table. I want to be able to query the database for a list of invoices that don't have a value for the extension attribute, using the API (and then insert the value for that extension attribute).
Here's the code that I have right now that adds the extension attribute to invoices.
public function afterGetList
(
MagentoSalesApiInvoiceRepositoryInterface $subject,
MagentoSalesModelResourceModelOrderInvoiceCollection $searchResult
) {
/** @var MagentoCatalogApiDataInvoiceInterface $invoice */
foreach ($searchResult as $invoice) {
$this->addExportedFlagToInvoice($invoice);
}
return $searchResult;
}
private function addExportedFlagToInvoice(MagentoSalesApiDataInvoiceInterface $invoice)
{
$extensionAttributes = $invoice->getExtensionAttributes();
if (empty($extensionAttributes)) {
$extensionAttributes = $this->invoiceExtensionFactory->create();
}
$exportedFlag = $this->exportedFlagProvider->getExportedFlag($invoice->getEntityId());
$extensionAttributes->setExportedFlag($exportedFlag);
$invoice->setExtensionAttributes($extensionAttributes);
$exportedFlag = $extensionAttributes->getExportedFlag();
$exportedFlag->setInvoiceId($invoice->getEntityId());
$this->entityManager->save($exportedFlag);
return $this;
}
The problem is that this code iterates through each invoice, and adds the extension attribute one-by-one. Furthermore, it retrieves all invoices, regardless of whether or not they have a value for the extension attribute (I don't want to retrieve values that have a row in the extension attributes table).
I want to be able to retrieve all invoices in a single query. Something like this
SELECT *
FROM sales_order_invoice
LEFT OUTER JOIN extensionAttribute
ON sales_order_invoice.entity_id = extensionAttribute.invoice_id
WHERE extensionAttribute.isExported IS NULL
How can I do this within Magento?
magento2 database extension-attributes
I added an extension attribute to the Invoice class, and I want to be able to query the Invoice database data by my extension attribute.
My extension attribute (ExportedFlag) has these properties
entity_idThe primary key
invoice_idThe foreign key to the invoice table.
isExportedA string value.
When an invoice gets created, it will not have a corresponding row in my extension attribute table. I want to be able to query the database for a list of invoices that don't have a value for the extension attribute, using the API (and then insert the value for that extension attribute).
Here's the code that I have right now that adds the extension attribute to invoices.
public function afterGetList
(
MagentoSalesApiInvoiceRepositoryInterface $subject,
MagentoSalesModelResourceModelOrderInvoiceCollection $searchResult
) {
/** @var MagentoCatalogApiDataInvoiceInterface $invoice */
foreach ($searchResult as $invoice) {
$this->addExportedFlagToInvoice($invoice);
}
return $searchResult;
}
private function addExportedFlagToInvoice(MagentoSalesApiDataInvoiceInterface $invoice)
{
$extensionAttributes = $invoice->getExtensionAttributes();
if (empty($extensionAttributes)) {
$extensionAttributes = $this->invoiceExtensionFactory->create();
}
$exportedFlag = $this->exportedFlagProvider->getExportedFlag($invoice->getEntityId());
$extensionAttributes->setExportedFlag($exportedFlag);
$invoice->setExtensionAttributes($extensionAttributes);
$exportedFlag = $extensionAttributes->getExportedFlag();
$exportedFlag->setInvoiceId($invoice->getEntityId());
$this->entityManager->save($exportedFlag);
return $this;
}
The problem is that this code iterates through each invoice, and adds the extension attribute one-by-one. Furthermore, it retrieves all invoices, regardless of whether or not they have a value for the extension attribute (I don't want to retrieve values that have a row in the extension attributes table).
I want to be able to retrieve all invoices in a single query. Something like this
SELECT *
FROM sales_order_invoice
LEFT OUTER JOIN extensionAttribute
ON sales_order_invoice.entity_id = extensionAttribute.invoice_id
WHERE extensionAttribute.isExported IS NULL
How can I do this within Magento?
magento2 database extension-attributes
magento2 database extension-attributes
asked 11 mins ago
Ben RubinBen Rubin
1828
1828
add a comment |
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
});
}
});
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%2f269605%2fhow-do-i-query-on-an-extension-attribute-through-the-api%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
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%2f269605%2fhow-do-i-query-on-an-extension-attribute-through-the-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