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
Why was ambassador Sondland involved in Ukraine?
Why do new jet engines cost billions to design?
Switching engine coolant with similar properties oil
When to use Sitecore.Context.Items and why?
How to truncate all lines at a certain length?
Selecting elements of a list based on range
Insets around a clock
Does Global Entry require agreeing to a higher standard of behavior?
TV Pilot or Movie, 80s, misfit team with powers
What is the last point where one can throw away fruits if one has indicated "not bringing any fruit" on the US customs form when flying to the US?
Does a resurrected wizard remember his prepared spells?
What kinds of sanctions would be applied if you wrongly invoked the fifth amendment?
Why is hydro-electric power still scarce in some places?
Does the coriolis force have an effect on the direction in which an aircraft travels?
What should I tell a customer when my co-worker fails to show up to a meeting?
Is there a text editor that can run shell scripts?
Is the genre 'fantasy' still fantasy without magic?
What is an example of a sequence which "thins out" and is finite?
Has Donald Duck ever had any love interest besides Daisy?
Why does Greedo say "Maclunkey" in the Mos Eisley Cantina?
Is there any math conjecture that would cause a lot of damage if disproven?
SMD ceramic capacitor 0805 vs 1206
How can mages regard fast magic as a form of evil?
Does casting Inflict Wounds while concentrating on Vampiric Touch also siphon damage?
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,7181 gold badge13 silver badges29 bronze badges
1,7181 gold badge13 silver badges29 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/4.0/"u003ecc by-sa 4.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,4001 gold badge3 silver badges23 bronze badges
1,4001 gold badge3 silver badges23 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,7671 gold badge9 silver badges40 bronze badges
4,7671 gold badge9 silver badges40 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