magento 2 sales_order_shipment_save_after does not fire
i create observer for change shipping method amount but it does not worked.
this is my code
Cop/Postexpres/etc/events.xml
<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_after">
<observer name="popopp" instance="CopPostexpresModelObserver" />
</event>
and
`Cop/Postexpres/Model/Observer.php'
namespace CopPostexpresObserver;
use MagentoFrameworkEventObserverInterface;
class Observer implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
var_dump($order->getData());
}
}
magento2 event-observer
add a comment |
i create observer for change shipping method amount but it does not worked.
this is my code
Cop/Postexpres/etc/events.xml
<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_after">
<observer name="popopp" instance="CopPostexpresModelObserver" />
</event>
and
`Cop/Postexpres/Model/Observer.php'
namespace CopPostexpresObserver;
use MagentoFrameworkEventObserverInterface;
class Observer implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
var_dump($order->getData());
}
}
magento2 event-observer
add a comment |
i create observer for change shipping method amount but it does not worked.
this is my code
Cop/Postexpres/etc/events.xml
<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_after">
<observer name="popopp" instance="CopPostexpresModelObserver" />
</event>
and
`Cop/Postexpres/Model/Observer.php'
namespace CopPostexpresObserver;
use MagentoFrameworkEventObserverInterface;
class Observer implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
var_dump($order->getData());
}
}
magento2 event-observer
i create observer for change shipping method amount but it does not worked.
this is my code
Cop/Postexpres/etc/events.xml
<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_after">
<observer name="popopp" instance="CopPostexpresModelObserver" />
</event>
and
`Cop/Postexpres/Model/Observer.php'
namespace CopPostexpresObserver;
use MagentoFrameworkEventObserverInterface;
class Observer implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
var_dump($order->getData());
}
}
magento2 event-observer
magento2 event-observer
edited 2 days ago
Asad Ullah
3410
3410
asked Jan 21 '18 at 7:24
gh darvishanigh darvishani
288215
288215
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
It looks like you passed wrong instance in your events.xml. You passed
<observer name="popopp" instance="CopPostexpresModelObserver" />
and your namespace Observer is
namespace CopPostexpresObserver;
So, you just need to add correct namespace(you are missing Model in your namespace).
oh sorry ... i was wrong about copy ... but in my code all namesapace and instance are true ...i was check it for sevral time
– gh darvishani
Jan 21 '18 at 9:34
1
Post your correct code here so peoples don't add as answer :)
– Keyur Shah
Jan 21 '18 at 9:36
paste.ubuntu.ir/ucln paste.ubuntu.ir/fmgd app/code/Netweb/Postexpres/etc/events.xml app/code/Netweb/Postexpres/Model/Observer.php
– gh darvishani
Jan 21 '18 at 10:18
1
And please also post your observer code @ghdarvishani
– Keyur Shah
Jan 21 '18 at 10:28
1
For temp log you can use this answer magento.stackexchange.com/a/92441/2589 it is very easy to debug
– Keyur Shah
Jan 21 '18 at 10:49
|
show 13 more comments
Try following code:
- app/code/[VendorName]/[ModuleName]/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_after">
<observer name="sales_order_shipment_save_after" instance="
[VendorName][ModuleName]ObserverProcessShipment" />
</event>
</config>
- app/code/[VendorName]/[ModuleName]/Observer/ProcessShipment.php
<?php
namespace [VendorName][ModuleName]Observer;
use MagentoFrameworkEventObserverInterface;
class ProcessShipment implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
}
}
Thanks .... i copy you code and replace company and module name ... and compile and flush cache ... but it doesn't worked
– gh darvishani
Jan 21 '18 at 7:54
1
@ghdarvishani - Maybe event "sales_order_shipment_save_after" is not available in M2.
– Pratik Oza
Jan 21 '18 at 11:16
omg :( ... how i can check it ... i found this event after many search
– gh darvishani
Jan 21 '18 at 11:19
You can check using command: find . -type f -exec grep -n -H -A 2 -T "eventManager->dispatch(" {} ;
– Pratik Oza
Jan 21 '18 at 11:24
1
I can confirm thatsales_order_shipment_save_afterevent is available in M2. I tested it and it works without any problem. @PratikOza
– Keyur Shah
Jan 21 '18 at 14:32
|
show 3 more comments
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%2f210317%2fmagento-2-sales-order-shipment-save-after-does-not-fire%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
It looks like you passed wrong instance in your events.xml. You passed
<observer name="popopp" instance="CopPostexpresModelObserver" />
and your namespace Observer is
namespace CopPostexpresObserver;
So, you just need to add correct namespace(you are missing Model in your namespace).
oh sorry ... i was wrong about copy ... but in my code all namesapace and instance are true ...i was check it for sevral time
– gh darvishani
Jan 21 '18 at 9:34
1
Post your correct code here so peoples don't add as answer :)
– Keyur Shah
Jan 21 '18 at 9:36
paste.ubuntu.ir/ucln paste.ubuntu.ir/fmgd app/code/Netweb/Postexpres/etc/events.xml app/code/Netweb/Postexpres/Model/Observer.php
– gh darvishani
Jan 21 '18 at 10:18
1
And please also post your observer code @ghdarvishani
– Keyur Shah
Jan 21 '18 at 10:28
1
For temp log you can use this answer magento.stackexchange.com/a/92441/2589 it is very easy to debug
– Keyur Shah
Jan 21 '18 at 10:49
|
show 13 more comments
It looks like you passed wrong instance in your events.xml. You passed
<observer name="popopp" instance="CopPostexpresModelObserver" />
and your namespace Observer is
namespace CopPostexpresObserver;
So, you just need to add correct namespace(you are missing Model in your namespace).
oh sorry ... i was wrong about copy ... but in my code all namesapace and instance are true ...i was check it for sevral time
– gh darvishani
Jan 21 '18 at 9:34
1
Post your correct code here so peoples don't add as answer :)
– Keyur Shah
Jan 21 '18 at 9:36
paste.ubuntu.ir/ucln paste.ubuntu.ir/fmgd app/code/Netweb/Postexpres/etc/events.xml app/code/Netweb/Postexpres/Model/Observer.php
– gh darvishani
Jan 21 '18 at 10:18
1
And please also post your observer code @ghdarvishani
– Keyur Shah
Jan 21 '18 at 10:28
1
For temp log you can use this answer magento.stackexchange.com/a/92441/2589 it is very easy to debug
– Keyur Shah
Jan 21 '18 at 10:49
|
show 13 more comments
It looks like you passed wrong instance in your events.xml. You passed
<observer name="popopp" instance="CopPostexpresModelObserver" />
and your namespace Observer is
namespace CopPostexpresObserver;
So, you just need to add correct namespace(you are missing Model in your namespace).
It looks like you passed wrong instance in your events.xml. You passed
<observer name="popopp" instance="CopPostexpresModelObserver" />
and your namespace Observer is
namespace CopPostexpresObserver;
So, you just need to add correct namespace(you are missing Model in your namespace).
answered Jan 21 '18 at 8:54
Keyur ShahKeyur Shah
12.9k23864
12.9k23864
oh sorry ... i was wrong about copy ... but in my code all namesapace and instance are true ...i was check it for sevral time
– gh darvishani
Jan 21 '18 at 9:34
1
Post your correct code here so peoples don't add as answer :)
– Keyur Shah
Jan 21 '18 at 9:36
paste.ubuntu.ir/ucln paste.ubuntu.ir/fmgd app/code/Netweb/Postexpres/etc/events.xml app/code/Netweb/Postexpres/Model/Observer.php
– gh darvishani
Jan 21 '18 at 10:18
1
And please also post your observer code @ghdarvishani
– Keyur Shah
Jan 21 '18 at 10:28
1
For temp log you can use this answer magento.stackexchange.com/a/92441/2589 it is very easy to debug
– Keyur Shah
Jan 21 '18 at 10:49
|
show 13 more comments
oh sorry ... i was wrong about copy ... but in my code all namesapace and instance are true ...i was check it for sevral time
– gh darvishani
Jan 21 '18 at 9:34
1
Post your correct code here so peoples don't add as answer :)
– Keyur Shah
Jan 21 '18 at 9:36
paste.ubuntu.ir/ucln paste.ubuntu.ir/fmgd app/code/Netweb/Postexpres/etc/events.xml app/code/Netweb/Postexpres/Model/Observer.php
– gh darvishani
Jan 21 '18 at 10:18
1
And please also post your observer code @ghdarvishani
– Keyur Shah
Jan 21 '18 at 10:28
1
For temp log you can use this answer magento.stackexchange.com/a/92441/2589 it is very easy to debug
– Keyur Shah
Jan 21 '18 at 10:49
oh sorry ... i was wrong about copy ... but in my code all namesapace and instance are true ...i was check it for sevral time
– gh darvishani
Jan 21 '18 at 9:34
oh sorry ... i was wrong about copy ... but in my code all namesapace and instance are true ...i was check it for sevral time
– gh darvishani
Jan 21 '18 at 9:34
1
1
Post your correct code here so peoples don't add as answer :)
– Keyur Shah
Jan 21 '18 at 9:36
Post your correct code here so peoples don't add as answer :)
– Keyur Shah
Jan 21 '18 at 9:36
paste.ubuntu.ir/ucln paste.ubuntu.ir/fmgd app/code/Netweb/Postexpres/etc/events.xml app/code/Netweb/Postexpres/Model/Observer.php
– gh darvishani
Jan 21 '18 at 10:18
paste.ubuntu.ir/ucln paste.ubuntu.ir/fmgd app/code/Netweb/Postexpres/etc/events.xml app/code/Netweb/Postexpres/Model/Observer.php
– gh darvishani
Jan 21 '18 at 10:18
1
1
And please also post your observer code @ghdarvishani
– Keyur Shah
Jan 21 '18 at 10:28
And please also post your observer code @ghdarvishani
– Keyur Shah
Jan 21 '18 at 10:28
1
1
For temp log you can use this answer magento.stackexchange.com/a/92441/2589 it is very easy to debug
– Keyur Shah
Jan 21 '18 at 10:49
For temp log you can use this answer magento.stackexchange.com/a/92441/2589 it is very easy to debug
– Keyur Shah
Jan 21 '18 at 10:49
|
show 13 more comments
Try following code:
- app/code/[VendorName]/[ModuleName]/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_after">
<observer name="sales_order_shipment_save_after" instance="
[VendorName][ModuleName]ObserverProcessShipment" />
</event>
</config>
- app/code/[VendorName]/[ModuleName]/Observer/ProcessShipment.php
<?php
namespace [VendorName][ModuleName]Observer;
use MagentoFrameworkEventObserverInterface;
class ProcessShipment implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
}
}
Thanks .... i copy you code and replace company and module name ... and compile and flush cache ... but it doesn't worked
– gh darvishani
Jan 21 '18 at 7:54
1
@ghdarvishani - Maybe event "sales_order_shipment_save_after" is not available in M2.
– Pratik Oza
Jan 21 '18 at 11:16
omg :( ... how i can check it ... i found this event after many search
– gh darvishani
Jan 21 '18 at 11:19
You can check using command: find . -type f -exec grep -n -H -A 2 -T "eventManager->dispatch(" {} ;
– Pratik Oza
Jan 21 '18 at 11:24
1
I can confirm thatsales_order_shipment_save_afterevent is available in M2. I tested it and it works without any problem. @PratikOza
– Keyur Shah
Jan 21 '18 at 14:32
|
show 3 more comments
Try following code:
- app/code/[VendorName]/[ModuleName]/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_after">
<observer name="sales_order_shipment_save_after" instance="
[VendorName][ModuleName]ObserverProcessShipment" />
</event>
</config>
- app/code/[VendorName]/[ModuleName]/Observer/ProcessShipment.php
<?php
namespace [VendorName][ModuleName]Observer;
use MagentoFrameworkEventObserverInterface;
class ProcessShipment implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
}
}
Thanks .... i copy you code and replace company and module name ... and compile and flush cache ... but it doesn't worked
– gh darvishani
Jan 21 '18 at 7:54
1
@ghdarvishani - Maybe event "sales_order_shipment_save_after" is not available in M2.
– Pratik Oza
Jan 21 '18 at 11:16
omg :( ... how i can check it ... i found this event after many search
– gh darvishani
Jan 21 '18 at 11:19
You can check using command: find . -type f -exec grep -n -H -A 2 -T "eventManager->dispatch(" {} ;
– Pratik Oza
Jan 21 '18 at 11:24
1
I can confirm thatsales_order_shipment_save_afterevent is available in M2. I tested it and it works without any problem. @PratikOza
– Keyur Shah
Jan 21 '18 at 14:32
|
show 3 more comments
Try following code:
- app/code/[VendorName]/[ModuleName]/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_after">
<observer name="sales_order_shipment_save_after" instance="
[VendorName][ModuleName]ObserverProcessShipment" />
</event>
</config>
- app/code/[VendorName]/[ModuleName]/Observer/ProcessShipment.php
<?php
namespace [VendorName][ModuleName]Observer;
use MagentoFrameworkEventObserverInterface;
class ProcessShipment implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
}
}
Try following code:
- app/code/[VendorName]/[ModuleName]/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_after">
<observer name="sales_order_shipment_save_after" instance="
[VendorName][ModuleName]ObserverProcessShipment" />
</event>
</config>
- app/code/[VendorName]/[ModuleName]/Observer/ProcessShipment.php
<?php
namespace [VendorName][ModuleName]Observer;
use MagentoFrameworkEventObserverInterface;
class ProcessShipment implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
}
}
answered Jan 21 '18 at 7:36
Pratik OzaPratik Oza
1,941311
1,941311
Thanks .... i copy you code and replace company and module name ... and compile and flush cache ... but it doesn't worked
– gh darvishani
Jan 21 '18 at 7:54
1
@ghdarvishani - Maybe event "sales_order_shipment_save_after" is not available in M2.
– Pratik Oza
Jan 21 '18 at 11:16
omg :( ... how i can check it ... i found this event after many search
– gh darvishani
Jan 21 '18 at 11:19
You can check using command: find . -type f -exec grep -n -H -A 2 -T "eventManager->dispatch(" {} ;
– Pratik Oza
Jan 21 '18 at 11:24
1
I can confirm thatsales_order_shipment_save_afterevent is available in M2. I tested it and it works without any problem. @PratikOza
– Keyur Shah
Jan 21 '18 at 14:32
|
show 3 more comments
Thanks .... i copy you code and replace company and module name ... and compile and flush cache ... but it doesn't worked
– gh darvishani
Jan 21 '18 at 7:54
1
@ghdarvishani - Maybe event "sales_order_shipment_save_after" is not available in M2.
– Pratik Oza
Jan 21 '18 at 11:16
omg :( ... how i can check it ... i found this event after many search
– gh darvishani
Jan 21 '18 at 11:19
You can check using command: find . -type f -exec grep -n -H -A 2 -T "eventManager->dispatch(" {} ;
– Pratik Oza
Jan 21 '18 at 11:24
1
I can confirm thatsales_order_shipment_save_afterevent is available in M2. I tested it and it works without any problem. @PratikOza
– Keyur Shah
Jan 21 '18 at 14:32
Thanks .... i copy you code and replace company and module name ... and compile and flush cache ... but it doesn't worked
– gh darvishani
Jan 21 '18 at 7:54
Thanks .... i copy you code and replace company and module name ... and compile and flush cache ... but it doesn't worked
– gh darvishani
Jan 21 '18 at 7:54
1
1
@ghdarvishani - Maybe event "sales_order_shipment_save_after" is not available in M2.
– Pratik Oza
Jan 21 '18 at 11:16
@ghdarvishani - Maybe event "sales_order_shipment_save_after" is not available in M2.
– Pratik Oza
Jan 21 '18 at 11:16
omg :( ... how i can check it ... i found this event after many search
– gh darvishani
Jan 21 '18 at 11:19
omg :( ... how i can check it ... i found this event after many search
– gh darvishani
Jan 21 '18 at 11:19
You can check using command: find . -type f -exec grep -n -H -A 2 -T "eventManager->dispatch(" {} ;
– Pratik Oza
Jan 21 '18 at 11:24
You can check using command: find . -type f -exec grep -n -H -A 2 -T "eventManager->dispatch(" {} ;
– Pratik Oza
Jan 21 '18 at 11:24
1
1
I can confirm that
sales_order_shipment_save_after event is available in M2. I tested it and it works without any problem. @PratikOza– Keyur Shah
Jan 21 '18 at 14:32
I can confirm that
sales_order_shipment_save_after event is available in M2. I tested it and it works without any problem. @PratikOza– Keyur Shah
Jan 21 '18 at 14:32
|
show 3 more comments
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%2f210317%2fmagento-2-sales-order-shipment-save-after-does-not-fire%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