API error when adding an extension attributedata: 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
Could Giant Ground Sloths have been a good pack animal for the ancient Mayans?
Where to refill my bottle in India?
Ideas for 3rd eye abilities
Is there a way to make member function NOT callable from constructor?
What happens when a metallic dragon and a chromatic dragon mate?
A poker game description that does not feel gimmicky
How could a lack of term limits lead to a "dictatorship?"
LWC and complex parameters
Can the Produce Flame cantrip be used to grapple, or as an unarmed strike, in the right circumstances?
Is ipsum/ipsa/ipse a third person pronoun, or can it serve other functions?
Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore
What does it exactly mean if a random variable follows a distribution
Was there ever an axiom rendered a theorem?
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
Are objects structures and/or vice versa?
Doomsday-clock for my fantasy planet
Why airport relocation isn't done gradually?
What is the command to reset a PC without deleting any files
How to make payment on the internet without leaving a money trail?
Calculate Levenshtein distance between two strings in Python
Are cabin dividers used to "hide" the flex of the airplane?
extract characters between two commas?
Landing in very high winds
When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?
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
7 hours ago
run upgrade then compile then indexer
– magefms
7 hours 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
edited 50 mins ago
ABHISHEK TRIPATHI
2,1441828
2,1441828
asked 7 hours ago
Ben RubinBen Rubin
1727
1727
did yun run upgrade and di compile after applying your configuration?
– magefms
7 hours ago
run upgrade then compile then indexer
– magefms
7 hours ago
add a comment |
did yun run upgrade and di compile after applying your configuration?
– magefms
7 hours ago
run upgrade then compile then indexer
– magefms
7 hours ago
did yun run upgrade and di compile after applying your configuration?
– magefms
7 hours ago
did yun run upgrade and di compile after applying your configuration?
– magefms
7 hours ago
run upgrade then compile then indexer
– magefms
7 hours ago
run upgrade then compile then indexer
– magefms
7 hours 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
7 hours ago
run upgrade then compile then indexer
– magefms
7 hours ago