REST API - dispatch events
I have custom module and my code structure is as per service contact.
app/code/[Vendor]/[Module]/Model/AccountManagement.php
Now i have a dispatch event in my model file
$this->_eventManager->dispatch('vendor_register_success', $eventParams);
As per REST API standard and as per the this solution i added event in specific module where it comes from.
app/code/[Vendor]/[Module]/etc/webapi_rest/events.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="vendor_register_success">
<observer name="vendor_register_success" instance="[Vendor][Module]ObserverVendorBrandRegister" />
</event>
</config>
and My observer looks like this
app/code/[Vendor]/[Module]/Observer/VendorBrandRegister.php
public function execute(MagentoFrameworkEventObserver $observer)
{
echo "In execute"; exit;
}
but this event is not dispatching.
What am i missing Because as per the solution i need to add events in webapi_rest
folder in etc
folder.
magento2 event-observer rest-api
add a comment |
I have custom module and my code structure is as per service contact.
app/code/[Vendor]/[Module]/Model/AccountManagement.php
Now i have a dispatch event in my model file
$this->_eventManager->dispatch('vendor_register_success', $eventParams);
As per REST API standard and as per the this solution i added event in specific module where it comes from.
app/code/[Vendor]/[Module]/etc/webapi_rest/events.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="vendor_register_success">
<observer name="vendor_register_success" instance="[Vendor][Module]ObserverVendorBrandRegister" />
</event>
</config>
and My observer looks like this
app/code/[Vendor]/[Module]/Observer/VendorBrandRegister.php
public function execute(MagentoFrameworkEventObserver $observer)
{
echo "In execute"; exit;
}
but this event is not dispatching.
What am i missing Because as per the solution i need to add events in webapi_rest
folder in etc
folder.
magento2 event-observer rest-api
add a comment |
I have custom module and my code structure is as per service contact.
app/code/[Vendor]/[Module]/Model/AccountManagement.php
Now i have a dispatch event in my model file
$this->_eventManager->dispatch('vendor_register_success', $eventParams);
As per REST API standard and as per the this solution i added event in specific module where it comes from.
app/code/[Vendor]/[Module]/etc/webapi_rest/events.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="vendor_register_success">
<observer name="vendor_register_success" instance="[Vendor][Module]ObserverVendorBrandRegister" />
</event>
</config>
and My observer looks like this
app/code/[Vendor]/[Module]/Observer/VendorBrandRegister.php
public function execute(MagentoFrameworkEventObserver $observer)
{
echo "In execute"; exit;
}
but this event is not dispatching.
What am i missing Because as per the solution i need to add events in webapi_rest
folder in etc
folder.
magento2 event-observer rest-api
I have custom module and my code structure is as per service contact.
app/code/[Vendor]/[Module]/Model/AccountManagement.php
Now i have a dispatch event in my model file
$this->_eventManager->dispatch('vendor_register_success', $eventParams);
As per REST API standard and as per the this solution i added event in specific module where it comes from.
app/code/[Vendor]/[Module]/etc/webapi_rest/events.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="vendor_register_success">
<observer name="vendor_register_success" instance="[Vendor][Module]ObserverVendorBrandRegister" />
</event>
</config>
and My observer looks like this
app/code/[Vendor]/[Module]/Observer/VendorBrandRegister.php
public function execute(MagentoFrameworkEventObserver $observer)
{
echo "In execute"; exit;
}
but this event is not dispatching.
What am i missing Because as per the solution i need to add events in webapi_rest
folder in etc
folder.
magento2 event-observer rest-api
magento2 event-observer rest-api
asked Jun 22 '18 at 6:46
Aditya ShahAditya Shah
3,7022834
3,7022834
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Try below code for dispatch event.
$this->_eventManager->dispatch('vendor_register_success', [$eventParams]);
Instead of
$this->_eventManager->dispatch('vendor_register_success', $eventParams);
As second parameter should be an array. This may help you.
Tried this solution. Not working.
– Aditya Shah
Jun 22 '18 at 10:03
It's specific webapi_rest related issue.. how todispatch event
in that.
– Aditya Shah
Jun 22 '18 at 10:04
You have done proper, I have seen only difference that I have mentioned. In my opinion First check the code s executed or not?
– Prasanta Hatui
Jun 22 '18 at 10:34
No, it's not going in execute function, now i am not magento allows or not dispatch event in model for service contact
– Aditya Shah
Jun 22 '18 at 10:39
1
+ for your efforts man !! :)
– Aditya Shah
Jun 22 '18 at 11:19
|
show 3 more comments
This can be done by defining events.xml
in webapi_rest
folder.
vendor/magento/module-quote/etc/webapi_rest/events.xml
Magento is doing it in quote module for sending mail.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_model_service_quote_submit_success">
<observer name="sendEmail" instance="MagentoQuoteObserverWebapiSubmitObserver" />
</event>
</config>
Reference 1 - From Vinai Kopp: https://twitter.com/VinaiKopp/status/810897855527485440
Reference 2
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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%2f230953%2frest-api-dispatch-events%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
Try below code for dispatch event.
$this->_eventManager->dispatch('vendor_register_success', [$eventParams]);
Instead of
$this->_eventManager->dispatch('vendor_register_success', $eventParams);
As second parameter should be an array. This may help you.
Tried this solution. Not working.
– Aditya Shah
Jun 22 '18 at 10:03
It's specific webapi_rest related issue.. how todispatch event
in that.
– Aditya Shah
Jun 22 '18 at 10:04
You have done proper, I have seen only difference that I have mentioned. In my opinion First check the code s executed or not?
– Prasanta Hatui
Jun 22 '18 at 10:34
No, it's not going in execute function, now i am not magento allows or not dispatch event in model for service contact
– Aditya Shah
Jun 22 '18 at 10:39
1
+ for your efforts man !! :)
– Aditya Shah
Jun 22 '18 at 11:19
|
show 3 more comments
Try below code for dispatch event.
$this->_eventManager->dispatch('vendor_register_success', [$eventParams]);
Instead of
$this->_eventManager->dispatch('vendor_register_success', $eventParams);
As second parameter should be an array. This may help you.
Tried this solution. Not working.
– Aditya Shah
Jun 22 '18 at 10:03
It's specific webapi_rest related issue.. how todispatch event
in that.
– Aditya Shah
Jun 22 '18 at 10:04
You have done proper, I have seen only difference that I have mentioned. In my opinion First check the code s executed or not?
– Prasanta Hatui
Jun 22 '18 at 10:34
No, it's not going in execute function, now i am not magento allows or not dispatch event in model for service contact
– Aditya Shah
Jun 22 '18 at 10:39
1
+ for your efforts man !! :)
– Aditya Shah
Jun 22 '18 at 11:19
|
show 3 more comments
Try below code for dispatch event.
$this->_eventManager->dispatch('vendor_register_success', [$eventParams]);
Instead of
$this->_eventManager->dispatch('vendor_register_success', $eventParams);
As second parameter should be an array. This may help you.
Try below code for dispatch event.
$this->_eventManager->dispatch('vendor_register_success', [$eventParams]);
Instead of
$this->_eventManager->dispatch('vendor_register_success', $eventParams);
As second parameter should be an array. This may help you.
answered Jun 22 '18 at 9:55
Prasanta HatuiPrasanta Hatui
1,4121414
1,4121414
Tried this solution. Not working.
– Aditya Shah
Jun 22 '18 at 10:03
It's specific webapi_rest related issue.. how todispatch event
in that.
– Aditya Shah
Jun 22 '18 at 10:04
You have done proper, I have seen only difference that I have mentioned. In my opinion First check the code s executed or not?
– Prasanta Hatui
Jun 22 '18 at 10:34
No, it's not going in execute function, now i am not magento allows or not dispatch event in model for service contact
– Aditya Shah
Jun 22 '18 at 10:39
1
+ for your efforts man !! :)
– Aditya Shah
Jun 22 '18 at 11:19
|
show 3 more comments
Tried this solution. Not working.
– Aditya Shah
Jun 22 '18 at 10:03
It's specific webapi_rest related issue.. how todispatch event
in that.
– Aditya Shah
Jun 22 '18 at 10:04
You have done proper, I have seen only difference that I have mentioned. In my opinion First check the code s executed or not?
– Prasanta Hatui
Jun 22 '18 at 10:34
No, it's not going in execute function, now i am not magento allows or not dispatch event in model for service contact
– Aditya Shah
Jun 22 '18 at 10:39
1
+ for your efforts man !! :)
– Aditya Shah
Jun 22 '18 at 11:19
Tried this solution. Not working.
– Aditya Shah
Jun 22 '18 at 10:03
Tried this solution. Not working.
– Aditya Shah
Jun 22 '18 at 10:03
It's specific webapi_rest related issue.. how to
dispatch event
in that.– Aditya Shah
Jun 22 '18 at 10:04
It's specific webapi_rest related issue.. how to
dispatch event
in that.– Aditya Shah
Jun 22 '18 at 10:04
You have done proper, I have seen only difference that I have mentioned. In my opinion First check the code s executed or not?
– Prasanta Hatui
Jun 22 '18 at 10:34
You have done proper, I have seen only difference that I have mentioned. In my opinion First check the code s executed or not?
– Prasanta Hatui
Jun 22 '18 at 10:34
No, it's not going in execute function, now i am not magento allows or not dispatch event in model for service contact
– Aditya Shah
Jun 22 '18 at 10:39
No, it's not going in execute function, now i am not magento allows or not dispatch event in model for service contact
– Aditya Shah
Jun 22 '18 at 10:39
1
1
+ for your efforts man !! :)
– Aditya Shah
Jun 22 '18 at 11:19
+ for your efforts man !! :)
– Aditya Shah
Jun 22 '18 at 11:19
|
show 3 more comments
This can be done by defining events.xml
in webapi_rest
folder.
vendor/magento/module-quote/etc/webapi_rest/events.xml
Magento is doing it in quote module for sending mail.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_model_service_quote_submit_success">
<observer name="sendEmail" instance="MagentoQuoteObserverWebapiSubmitObserver" />
</event>
</config>
Reference 1 - From Vinai Kopp: https://twitter.com/VinaiKopp/status/810897855527485440
Reference 2
add a comment |
This can be done by defining events.xml
in webapi_rest
folder.
vendor/magento/module-quote/etc/webapi_rest/events.xml
Magento is doing it in quote module for sending mail.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_model_service_quote_submit_success">
<observer name="sendEmail" instance="MagentoQuoteObserverWebapiSubmitObserver" />
</event>
</config>
Reference 1 - From Vinai Kopp: https://twitter.com/VinaiKopp/status/810897855527485440
Reference 2
add a comment |
This can be done by defining events.xml
in webapi_rest
folder.
vendor/magento/module-quote/etc/webapi_rest/events.xml
Magento is doing it in quote module for sending mail.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_model_service_quote_submit_success">
<observer name="sendEmail" instance="MagentoQuoteObserverWebapiSubmitObserver" />
</event>
</config>
Reference 1 - From Vinai Kopp: https://twitter.com/VinaiKopp/status/810897855527485440
Reference 2
This can be done by defining events.xml
in webapi_rest
folder.
vendor/magento/module-quote/etc/webapi_rest/events.xml
Magento is doing it in quote module for sending mail.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_model_service_quote_submit_success">
<observer name="sendEmail" instance="MagentoQuoteObserverWebapiSubmitObserver" />
</event>
</config>
Reference 1 - From Vinai Kopp: https://twitter.com/VinaiKopp/status/810897855527485440
Reference 2
answered 5 mins ago
Aditya ShahAditya Shah
3,7022834
3,7022834
add a comment |
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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%2f230953%2frest-api-dispatch-events%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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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