How do I create an events observer that only calls when the REST API dispatches events?How to get the name of the triggered event?How to obtain a JSON order rendered by the REST API in the sales_order_place_after event observerMagento2: frontend event is not working (sales_order_place_after)Magento 2.1.1 Rest API Update price onlyM2: Why My Observer Is Not Firing For API CallsMagento 2 - Category Save Event is not called when save category via rest apiHow to get Product via API right after product created?REST API - dispatch eventsEvents when the order is placed is not firing
Circular Reasoning for Epsilon-Delta Proof?
How do I make my image comply with the requirements of this photography competition?
How can I unambiguously ask for a new user's "Display Name"?
Nothing like a good ol' game of ModTen
Compelling story with the world as a villain
How to find out the average duration of the peer-review process for a given journal?
Can I get temporary health insurance while moving to the US?
Papers on arXiv solving the same problem at the same time
Where was Carl Sagan working on a plan to detonate a nuke on the Moon? Where was he applying when he leaked it?
Are the players on the same team as the DM?
Prevent use of CNAME Record for Untrusted Domain
Are modern clipless shoes and pedals that much better than toe clips and straps?
Could George I (of Great Britain) speak English?
How do the Etherealness and Banishment spells interact?
Does an atom recoil when photon radiate?
Can RMSE and MAE have the same value?
How to gently end involvement with an online community?
Numbers Decrease while Letters Increase
What would make bones be of different colors?
Is MOSFET active device?
Network helper class with retry logic on failure
Is "The life is beautiful" incorrect or just very non-idiomatic?
Do they have Supervillain(s)?
Did anyone try to find the little box that held Professor Moriarty and his wife after the crash?
How do I create an events observer that only calls when the REST API dispatches events?
How to get the name of the triggered event?How to obtain a JSON order rendered by the REST API in the sales_order_place_after event observerMagento2: frontend event is not working (sales_order_place_after)Magento 2.1.1 Rest API Update price onlyM2: Why My Observer Is Not Firing For API CallsMagento 2 - Category Save Event is not called when save category via rest apiHow to get Product via API right after product created?REST API - dispatch eventsEvents when the order is placed is not firing
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I just want to call an event observer when the event is dispatched via the REST API. Like if an order is placed from a mobile application, only then the sales_order_save_after
Observer should be called.
How do I write code for the same in events.xml
? Or do we have to write somewhere else?
magento2 event-observer rest
add a comment |
I just want to call an event observer when the event is dispatched via the REST API. Like if an order is placed from a mobile application, only then the sales_order_save_after
Observer should be called.
How do I write code for the same in events.xml
? Or do we have to write somewhere else?
magento2 event-observer rest
add a comment |
I just want to call an event observer when the event is dispatched via the REST API. Like if an order is placed from a mobile application, only then the sales_order_save_after
Observer should be called.
How do I write code for the same in events.xml
? Or do we have to write somewhere else?
magento2 event-observer rest
I just want to call an event observer when the event is dispatched via the REST API. Like if an order is placed from a mobile application, only then the sales_order_save_after
Observer should be called.
How do I write code for the same in events.xml
? Or do we have to write somewhere else?
magento2 event-observer rest
magento2 event-observer rest
edited Aug 13 at 4:06
Peter Mortensen
2091 silver badge8 bronze badges
2091 silver badge8 bronze badges
asked Aug 12 at 10:41
Navin BhudiyaNavin Bhudiya
1,0281 gold badge13 silver badges28 bronze badges
1,0281 gold badge13 silver badges28 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You have to place a events.xml
in the webapi_rest
area: app/[Vendor]/[Module]/etc/webapi_rest/events.xml
By placing the events.xml in the webapi_rest
directory the observer only listens to events dispatched in that area.
You can read about the areas and events in the devdocs.
How can i print what event currently i am using into log file @Daniel
– zus
Aug 14 at 9:18
@zus You'll need to injectPsrLogLoggerInterface
to write to the log. WIth$observer->getEventName()
you can get the current event name.
– Daniel
Aug 14 at 10:08
For magento 1, how can i do that?
– zus
Aug 14 at 10:09
here is my code, not working paste.ofcode.org/UuYfuMtnh84raJux5rUF8A
– zus
Aug 14 at 10:16
Sorry I don't know for Magento 1. You might ask a separate question for this.
– Daniel
Aug 14 at 10:35
|
show 1 more comment
You can declare your observer at the following location to call it via the REST API only.
app/code/Vendor/Module/etc/webapi_rest/events.xml
How can i print what event currently i am using into log file @Dinesh
– zus
Aug 14 at 9:18
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%2f285144%2fhow-do-i-create-an-events-observer-that-only-calls-when-the-rest-api-dispatches%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have to place a events.xml
in the webapi_rest
area: app/[Vendor]/[Module]/etc/webapi_rest/events.xml
By placing the events.xml in the webapi_rest
directory the observer only listens to events dispatched in that area.
You can read about the areas and events in the devdocs.
How can i print what event currently i am using into log file @Daniel
– zus
Aug 14 at 9:18
@zus You'll need to injectPsrLogLoggerInterface
to write to the log. WIth$observer->getEventName()
you can get the current event name.
– Daniel
Aug 14 at 10:08
For magento 1, how can i do that?
– zus
Aug 14 at 10:09
here is my code, not working paste.ofcode.org/UuYfuMtnh84raJux5rUF8A
– zus
Aug 14 at 10:16
Sorry I don't know for Magento 1. You might ask a separate question for this.
– Daniel
Aug 14 at 10:35
|
show 1 more comment
You have to place a events.xml
in the webapi_rest
area: app/[Vendor]/[Module]/etc/webapi_rest/events.xml
By placing the events.xml in the webapi_rest
directory the observer only listens to events dispatched in that area.
You can read about the areas and events in the devdocs.
How can i print what event currently i am using into log file @Daniel
– zus
Aug 14 at 9:18
@zus You'll need to injectPsrLogLoggerInterface
to write to the log. WIth$observer->getEventName()
you can get the current event name.
– Daniel
Aug 14 at 10:08
For magento 1, how can i do that?
– zus
Aug 14 at 10:09
here is my code, not working paste.ofcode.org/UuYfuMtnh84raJux5rUF8A
– zus
Aug 14 at 10:16
Sorry I don't know for Magento 1. You might ask a separate question for this.
– Daniel
Aug 14 at 10:35
|
show 1 more comment
You have to place a events.xml
in the webapi_rest
area: app/[Vendor]/[Module]/etc/webapi_rest/events.xml
By placing the events.xml in the webapi_rest
directory the observer only listens to events dispatched in that area.
You can read about the areas and events in the devdocs.
You have to place a events.xml
in the webapi_rest
area: app/[Vendor]/[Module]/etc/webapi_rest/events.xml
By placing the events.xml in the webapi_rest
directory the observer only listens to events dispatched in that area.
You can read about the areas and events in the devdocs.
edited Aug 12 at 11:34
answered Aug 12 at 11:01
DanielDaniel
1,0911 gold badge3 silver badges19 bronze badges
1,0911 gold badge3 silver badges19 bronze badges
How can i print what event currently i am using into log file @Daniel
– zus
Aug 14 at 9:18
@zus You'll need to injectPsrLogLoggerInterface
to write to the log. WIth$observer->getEventName()
you can get the current event name.
– Daniel
Aug 14 at 10:08
For magento 1, how can i do that?
– zus
Aug 14 at 10:09
here is my code, not working paste.ofcode.org/UuYfuMtnh84raJux5rUF8A
– zus
Aug 14 at 10:16
Sorry I don't know for Magento 1. You might ask a separate question for this.
– Daniel
Aug 14 at 10:35
|
show 1 more comment
How can i print what event currently i am using into log file @Daniel
– zus
Aug 14 at 9:18
@zus You'll need to injectPsrLogLoggerInterface
to write to the log. WIth$observer->getEventName()
you can get the current event name.
– Daniel
Aug 14 at 10:08
For magento 1, how can i do that?
– zus
Aug 14 at 10:09
here is my code, not working paste.ofcode.org/UuYfuMtnh84raJux5rUF8A
– zus
Aug 14 at 10:16
Sorry I don't know for Magento 1. You might ask a separate question for this.
– Daniel
Aug 14 at 10:35
How can i print what event currently i am using into log file @Daniel
– zus
Aug 14 at 9:18
How can i print what event currently i am using into log file @Daniel
– zus
Aug 14 at 9:18
@zus You'll need to inject
PsrLogLoggerInterface
to write to the log. WIth $observer->getEventName()
you can get the current event name.– Daniel
Aug 14 at 10:08
@zus You'll need to inject
PsrLogLoggerInterface
to write to the log. WIth $observer->getEventName()
you can get the current event name.– Daniel
Aug 14 at 10:08
For magento 1, how can i do that?
– zus
Aug 14 at 10:09
For magento 1, how can i do that?
– zus
Aug 14 at 10:09
here is my code, not working paste.ofcode.org/UuYfuMtnh84raJux5rUF8A
– zus
Aug 14 at 10:16
here is my code, not working paste.ofcode.org/UuYfuMtnh84raJux5rUF8A
– zus
Aug 14 at 10:16
Sorry I don't know for Magento 1. You might ask a separate question for this.
– Daniel
Aug 14 at 10:35
Sorry I don't know for Magento 1. You might ask a separate question for this.
– Daniel
Aug 14 at 10:35
|
show 1 more comment
You can declare your observer at the following location to call it via the REST API only.
app/code/Vendor/Module/etc/webapi_rest/events.xml
How can i print what event currently i am using into log file @Dinesh
– zus
Aug 14 at 9:18
add a comment |
You can declare your observer at the following location to call it via the REST API only.
app/code/Vendor/Module/etc/webapi_rest/events.xml
How can i print what event currently i am using into log file @Dinesh
– zus
Aug 14 at 9:18
add a comment |
You can declare your observer at the following location to call it via the REST API only.
app/code/Vendor/Module/etc/webapi_rest/events.xml
You can declare your observer at the following location to call it via the REST API only.
app/code/Vendor/Module/etc/webapi_rest/events.xml
edited Aug 13 at 4:06
Peter Mortensen
2091 silver badge8 bronze badges
2091 silver badge8 bronze badges
answered Aug 12 at 10:59
Dinesh YadavDinesh Yadav
4,4241 gold badge9 silver badges38 bronze badges
4,4241 gold badge9 silver badges38 bronze badges
How can i print what event currently i am using into log file @Dinesh
– zus
Aug 14 at 9:18
add a comment |
How can i print what event currently i am using into log file @Dinesh
– zus
Aug 14 at 9:18
How can i print what event currently i am using into log file @Dinesh
– zus
Aug 14 at 9:18
How can i print what event currently i am using into log file @Dinesh
– zus
Aug 14 at 9:18
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%2f285144%2fhow-do-i-create-an-events-observer-that-only-calls-when-the-rest-api-dispatches%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