API error when adding an extension attributedata: current version - none, required version - 2.0.0Magento...
Eliminate empty elements from a list with a specific pattern
Was there ever an axiom rendered a theorem?
Is there a way to make member function NOT callable from constructor?
OA final episode explanation
Mapping arrows in commutative diagrams
Need help identifying/translating a plaque in Tangier, Morocco
What is GPS' 19 year rollover and does it present a cybersecurity issue?
If a centaur druid Wild Shapes into a Giant Elk, do their Charge features stack?
How to move the player while also allowing forces to affect it
Why airport relocation isn't done gradually?
Deciding between multiple birth names and dates?
What to wear for invited talk in Canada
How to manage monthly salary
Could Giant Ground Sloths have been a Good Pack Animal for the Ancient Mayans
Is there a familial term for apples and pears?
"listening to me about as much as you're listening to this pole here"
What is the offset in a seaplane's hull?
Calculate Levenshtein distance between two strings in Python
Does the average primeness of natural numbers tend to zero?
What is the command to reset a PC without deleting any files
Is "plugging out" electronic devices an American expression?
Is a car considered movable or immovable property?
Unbreakable Formation vs. Cry of the Carnarium
Can produce flame be used to grapple, or as an unarmed strike, in the right circumstances?
API error when adding an extension attribute
data: current version - none, required version - 2.0.0Magento 2.2.2 REST API - I need to change the customer password using REST APIHow to solve Front controller reached 100 router match iterations in magento2Add configure product in Cart using Magento 2 API facing an issueMagento 2 Front controller reached 100 router match iterations issueError in collectionsMagento2 REST API get all customers detailsDeleted ShipperHQ module causing error in “All Customers” section of Magento 2“Area code is not set” in var/logwhen click on place order then paypal showing error in Magento2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm trying to follow Magento's tutorial for adding an extension attribute. I want to add an extension attribute called "exportedFlag" to the Invoice class, and have it returned through the V1/invoices/ API method.
Here's my API call
http://magento.test/rest/V1/invoices/?
searchCriteria[filter_groups][0][filters][0][field]=store_id&
searchCriteria[filter_groups][0][filters][0][value]=1&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq
Here's the error I'm getting:
Fatal Error: 'Uncaught TypeError: Argument 2 passed to
MyCompany\Invoice\Model\Plugin\Invoice\Repository::afterGetList()
must be an instance of Magento\Framework\Api\SearchResults,
instance of Magento\Sales\Model\ResourceModel\Order\Invoice\Collection given,
called in /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php
on line 146 and defined in
/var/www/magento2/app/code/MyCompany/Invoice/Model/Plugin/Invoice/Repository.php:53
Stack trace:
#0 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(146):
MyCompany\Invoice\Model\Plugin\Invoice\Repository->afterGetList(Object(Magento\Sales\Model\Order\InvoiceRepository\Interceptor),
Object(Magento\Sales\Model\ResourceModel\Order\Invoice\Collection),
Object(Magento\Framework\Api\SearchCriteria))
#1 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153):
Magento\Sales\Model\Order\InvoiceRepository\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\Api\SearchCriteria))
#2 /var/www/mag' in '/var/www/magento2/app/code/MyCompany/Invoice/Model/Plugin/Invoice/Repository.php' on line 53
Here's the relevant code
/**
* Class Repository
* @package MyCompanyInvoiceModelPluginInvoice
*/
class Repository
{
/**
* Adds the "exported flag" to invoice extension attributes.
*
* @param MagentoSalesApiInvoiceRepositoryInterface $subject
* @param MagentoFrameworkApiSearchCriteriaInterface $searchCriteria
* @return MagentoFrameworkApiSearchResults
*/
public function afterGetList
(
MagentoSalesApiInvoiceRepositoryInterface $subject,
MagentoFrameworkApiSearchResults $searchResult
) {
/** @var MagentoCatalogApiDataInvoiceInterface $invoice */
foreach ($searchResult->getItems() as $invoice) {
$this->addExportedFlagToInvoice($invoice);
}
return $searchResult;
}
}
For reference, here's the comparable bit of code from Magento's Github example
/**
* Class Repository
* @package MyCompanyInvoiceModelPluginInvoice
*/
class Repository
{
/**
* Add Social Links to product extension attributes
*
* @param MagentoCatalogApiProductRepositoryInterface $subject
* @param MagentoFrameworkApiSearchCriteriaInterface $searchCriteria
* @return MagentoFrameworkApiSearchResults
*/
public function afterGetList
(
MagentoCatalogApiProductRepositoryInterface $subject,
MagentoFrameworkApiSearchResults $searchResult
) {
/** @var MagentoCatalogApiDataProductInterface $product */
foreach ($searchResult->getItems() as $product) {
$this->addExternalLinksToProduct($product);
}
return $searchResult;
}
}
Why is Magento passing an instance of Magento\Sales\Model\ResourceModel\Order\Invoice\Collection as my second parameter to afterGetList, when Magento's example shows that the second parameter should be MagentoFrameworkApiSearchResults?
magento2 api extension-attributes
add a comment |
I'm trying to follow Magento's tutorial for adding an extension attribute. I want to add an extension attribute called "exportedFlag" to the Invoice class, and have it returned through the V1/invoices/ API method.
Here's my API call
http://magento.test/rest/V1/invoices/?
searchCriteria[filter_groups][0][filters][0][field]=store_id&
searchCriteria[filter_groups][0][filters][0][value]=1&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq
Here's the error I'm getting:
Fatal Error: 'Uncaught TypeError: Argument 2 passed to
MyCompany\Invoice\Model\Plugin\Invoice\Repository::afterGetList()
must be an instance of Magento\Framework\Api\SearchResults,
instance of Magento\Sales\Model\ResourceModel\Order\Invoice\Collection given,
called in /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php
on line 146 and defined in
/var/www/magento2/app/code/MyCompany/Invoice/Model/Plugin/Invoice/Repository.php:53
Stack trace:
#0 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(146):
MyCompany\Invoice\Model\Plugin\Invoice\Repository->afterGetList(Object(Magento\Sales\Model\Order\InvoiceRepository\Interceptor),
Object(Magento\Sales\Model\ResourceModel\Order\Invoice\Collection),
Object(Magento\Framework\Api\SearchCriteria))
#1 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153):
Magento\Sales\Model\Order\InvoiceRepository\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\Api\SearchCriteria))
#2 /var/www/mag' in '/var/www/magento2/app/code/MyCompany/Invoice/Model/Plugin/Invoice/Repository.php' on line 53
Here's the relevant code
/**
* Class Repository
* @package MyCompanyInvoiceModelPluginInvoice
*/
class Repository
{
/**
* Adds the "exported flag" to invoice extension attributes.
*
* @param MagentoSalesApiInvoiceRepositoryInterface $subject
* @param MagentoFrameworkApiSearchCriteriaInterface $searchCriteria
* @return MagentoFrameworkApiSearchResults
*/
public function afterGetList
(
MagentoSalesApiInvoiceRepositoryInterface $subject,
MagentoFrameworkApiSearchResults $searchResult
) {
/** @var MagentoCatalogApiDataInvoiceInterface $invoice */
foreach ($searchResult->getItems() as $invoice) {
$this->addExportedFlagToInvoice($invoice);
}
return $searchResult;
}
}
For reference, here's the comparable bit of code from Magento's Github example
/**
* Class Repository
* @package MyCompanyInvoiceModelPluginInvoice
*/
class Repository
{
/**
* Add Social Links to product extension attributes
*
* @param MagentoCatalogApiProductRepositoryInterface $subject
* @param MagentoFrameworkApiSearchCriteriaInterface $searchCriteria
* @return MagentoFrameworkApiSearchResults
*/
public function afterGetList
(
MagentoCatalogApiProductRepositoryInterface $subject,
MagentoFrameworkApiSearchResults $searchResult
) {
/** @var MagentoCatalogApiDataProductInterface $product */
foreach ($searchResult->getItems() as $product) {
$this->addExternalLinksToProduct($product);
}
return $searchResult;
}
}
Why is Magento passing an instance of Magento\Sales\Model\ResourceModel\Order\Invoice\Collection as my second parameter to afterGetList, when Magento's example shows that the second parameter should be MagentoFrameworkApiSearchResults?
magento2 api extension-attributes
did yun run upgrade and di compile after applying your configuration?
– magefms
27 mins ago
run upgrade then compile then indexer
– magefms
26 mins ago
add a comment |
I'm trying to follow Magento's tutorial for adding an extension attribute. I want to add an extension attribute called "exportedFlag" to the Invoice class, and have it returned through the V1/invoices/ API method.
Here's my API call
http://magento.test/rest/V1/invoices/?
searchCriteria[filter_groups][0][filters][0][field]=store_id&
searchCriteria[filter_groups][0][filters][0][value]=1&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq
Here's the error I'm getting:
Fatal Error: 'Uncaught TypeError: Argument 2 passed to
MyCompany\Invoice\Model\Plugin\Invoice\Repository::afterGetList()
must be an instance of Magento\Framework\Api\SearchResults,
instance of Magento\Sales\Model\ResourceModel\Order\Invoice\Collection given,
called in /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php
on line 146 and defined in
/var/www/magento2/app/code/MyCompany/Invoice/Model/Plugin/Invoice/Repository.php:53
Stack trace:
#0 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(146):
MyCompany\Invoice\Model\Plugin\Invoice\Repository->afterGetList(Object(Magento\Sales\Model\Order\InvoiceRepository\Interceptor),
Object(Magento\Sales\Model\ResourceModel\Order\Invoice\Collection),
Object(Magento\Framework\Api\SearchCriteria))
#1 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153):
Magento\Sales\Model\Order\InvoiceRepository\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\Api\SearchCriteria))
#2 /var/www/mag' in '/var/www/magento2/app/code/MyCompany/Invoice/Model/Plugin/Invoice/Repository.php' on line 53
Here's the relevant code
/**
* Class Repository
* @package MyCompanyInvoiceModelPluginInvoice
*/
class Repository
{
/**
* Adds the "exported flag" to invoice extension attributes.
*
* @param MagentoSalesApiInvoiceRepositoryInterface $subject
* @param MagentoFrameworkApiSearchCriteriaInterface $searchCriteria
* @return MagentoFrameworkApiSearchResults
*/
public function afterGetList
(
MagentoSalesApiInvoiceRepositoryInterface $subject,
MagentoFrameworkApiSearchResults $searchResult
) {
/** @var MagentoCatalogApiDataInvoiceInterface $invoice */
foreach ($searchResult->getItems() as $invoice) {
$this->addExportedFlagToInvoice($invoice);
}
return $searchResult;
}
}
For reference, here's the comparable bit of code from Magento's Github example
/**
* Class Repository
* @package MyCompanyInvoiceModelPluginInvoice
*/
class Repository
{
/**
* Add Social Links to product extension attributes
*
* @param MagentoCatalogApiProductRepositoryInterface $subject
* @param MagentoFrameworkApiSearchCriteriaInterface $searchCriteria
* @return MagentoFrameworkApiSearchResults
*/
public function afterGetList
(
MagentoCatalogApiProductRepositoryInterface $subject,
MagentoFrameworkApiSearchResults $searchResult
) {
/** @var MagentoCatalogApiDataProductInterface $product */
foreach ($searchResult->getItems() as $product) {
$this->addExternalLinksToProduct($product);
}
return $searchResult;
}
}
Why is Magento passing an instance of Magento\Sales\Model\ResourceModel\Order\Invoice\Collection as my second parameter to afterGetList, when Magento's example shows that the second parameter should be MagentoFrameworkApiSearchResults?
magento2 api extension-attributes
I'm trying to follow Magento's tutorial for adding an extension attribute. I want to add an extension attribute called "exportedFlag" to the Invoice class, and have it returned through the V1/invoices/ API method.
Here's my API call
http://magento.test/rest/V1/invoices/?
searchCriteria[filter_groups][0][filters][0][field]=store_id&
searchCriteria[filter_groups][0][filters][0][value]=1&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq
Here's the error I'm getting:
Fatal Error: 'Uncaught TypeError: Argument 2 passed to
MyCompany\Invoice\Model\Plugin\Invoice\Repository::afterGetList()
must be an instance of Magento\Framework\Api\SearchResults,
instance of Magento\Sales\Model\ResourceModel\Order\Invoice\Collection given,
called in /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php
on line 146 and defined in
/var/www/magento2/app/code/MyCompany/Invoice/Model/Plugin/Invoice/Repository.php:53
Stack trace:
#0 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(146):
MyCompany\Invoice\Model\Plugin\Invoice\Repository->afterGetList(Object(Magento\Sales\Model\Order\InvoiceRepository\Interceptor),
Object(Magento\Sales\Model\ResourceModel\Order\Invoice\Collection),
Object(Magento\Framework\Api\SearchCriteria))
#1 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153):
Magento\Sales\Model\Order\InvoiceRepository\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\Api\SearchCriteria))
#2 /var/www/mag' in '/var/www/magento2/app/code/MyCompany/Invoice/Model/Plugin/Invoice/Repository.php' on line 53
Here's the relevant code
/**
* Class Repository
* @package MyCompanyInvoiceModelPluginInvoice
*/
class Repository
{
/**
* Adds the "exported flag" to invoice extension attributes.
*
* @param MagentoSalesApiInvoiceRepositoryInterface $subject
* @param MagentoFrameworkApiSearchCriteriaInterface $searchCriteria
* @return MagentoFrameworkApiSearchResults
*/
public function afterGetList
(
MagentoSalesApiInvoiceRepositoryInterface $subject,
MagentoFrameworkApiSearchResults $searchResult
) {
/** @var MagentoCatalogApiDataInvoiceInterface $invoice */
foreach ($searchResult->getItems() as $invoice) {
$this->addExportedFlagToInvoice($invoice);
}
return $searchResult;
}
}
For reference, here's the comparable bit of code from Magento's Github example
/**
* Class Repository
* @package MyCompanyInvoiceModelPluginInvoice
*/
class Repository
{
/**
* Add Social Links to product extension attributes
*
* @param MagentoCatalogApiProductRepositoryInterface $subject
* @param MagentoFrameworkApiSearchCriteriaInterface $searchCriteria
* @return MagentoFrameworkApiSearchResults
*/
public function afterGetList
(
MagentoCatalogApiProductRepositoryInterface $subject,
MagentoFrameworkApiSearchResults $searchResult
) {
/** @var MagentoCatalogApiDataProductInterface $product */
foreach ($searchResult->getItems() as $product) {
$this->addExternalLinksToProduct($product);
}
return $searchResult;
}
}
Why is Magento passing an instance of Magento\Sales\Model\ResourceModel\Order\Invoice\Collection as my second parameter to afterGetList, when Magento's example shows that the second parameter should be MagentoFrameworkApiSearchResults?
magento2 api extension-attributes
magento2 api extension-attributes
asked 53 mins ago
Ben RubinBen Rubin
1727
1727
did yun run upgrade and di compile after applying your configuration?
– magefms
27 mins ago
run upgrade then compile then indexer
– magefms
26 mins ago
add a comment |
did yun run upgrade and di compile after applying your configuration?
– magefms
27 mins ago
run upgrade then compile then indexer
– magefms
26 mins ago
did yun run upgrade and di compile after applying your configuration?
– magefms
27 mins ago
did yun run upgrade and di compile after applying your configuration?
– magefms
27 mins ago
run upgrade then compile then indexer
– magefms
26 mins ago
run upgrade then compile then indexer
– magefms
26 mins ago
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%2f269251%2fapi-error-when-adding-an-extension-attribute%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%2f269251%2fapi-error-when-adding-an-extension-attribute%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
did yun run upgrade and di compile after applying your configuration?
– magefms
27 mins ago
run upgrade then compile then indexer
– magefms
26 mins ago