Magento 2 - How to call sales_order_save_after Observer manually for testing?Unit Test for overwrite collection class in magento2sales_order_shipment_track_save_after get order IDSet custom price of product when adding to cart code not workingMagento 2: How to override newsletter Subscriber modelMagento 2: Add a product to the cart programmaticallyI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom OptionsHow to print order details for event observer sales_order_save_afterHow to alert in sales_order_save_after observer?Magento 2.2.2 error when setting order status with API
Is declining an undergraduate award which causes me discomfort appropriate?
How does a blind passenger not die, if driver becomes unconscious
Number of solutions mod p and Betti numbers
Why is it easier to balance a non-moving bike standing up than sitting down?
Understanding the reasoning of the woman who agreed with Shlomo to "cut the baby in half"
Can I enter the UK for 24 hours from a Schengen area, holding an Indian passport?
What is appropriate short form for "laboratoires" in French?
Cut the gold chain
What is the highest voltage from the power supply a Raspberry Pi 3 B can handle without getting damaged?
How can I get my left hand to sound legato when I'm leaping?
How to remove this component from PCB
Heavily limited premature compiler translates text into excecutable python code
If the Dragon's Breath spell is cast on a familiar, does it use the wizard's DC or familiar's DC?
Trainee keeps passing deadlines for independent learning
Story about hunting giant lizards for hides on privately owned planet
DBCC checkdb on tempdb
Is "Busen" just the area between the breasts?
When to remove insignificant variables?
Why are < or > required to use /dev/tcp
Why does cooking oatmeal starting with cold milk make it creamy?
What can I do with a research project that is my university’s intellectual property?
Intuition for the role of diffeomorphisms
Why does the Saturn V have standalone inter-stage rings?
Explain why a line can never intersect a plane in exactly two points.
Magento 2 - How to call sales_order_save_after Observer manually for testing?
Unit Test for overwrite collection class in magento2sales_order_shipment_track_save_after get order IDSet custom price of product when adding to cart code not workingMagento 2: How to override newsletter Subscriber modelMagento 2: Add a product to the cart programmaticallyI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom OptionsHow to print order details for event observer sales_order_save_afterHow to alert in sales_order_save_after observer?Magento 2.2.2 error when setting order status with API
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
i have a working Observer on the event sales_order_save_after.
The Observer looks like this:
namespace CompanyExportOrderObserver;
use MagentoFrameworkEventObserverInterface;
class Observer implements ObserverInterface
protected $connector; public function __construct()
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
$orderId = $order->getId();
$customerId = $order->getCustomerId();
// do something
How am i able to call this Observer manually for testing? I don´t really want to create orders again and again. Idea is something like this:
$model = $objectManager->create('CompanyExportOrderObserverObserver');
$model->execute();
But the execute-Function expects the Observer Model, and how can i set the order id manually for testing the function?
magento2 event-observer sales-order sales
add a comment |
i have a working Observer on the event sales_order_save_after.
The Observer looks like this:
namespace CompanyExportOrderObserver;
use MagentoFrameworkEventObserverInterface;
class Observer implements ObserverInterface
protected $connector; public function __construct()
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
$orderId = $order->getId();
$customerId = $order->getCustomerId();
// do something
How am i able to call this Observer manually for testing? I don´t really want to create orders again and again. Idea is something like this:
$model = $objectManager->create('CompanyExportOrderObserverObserver');
$model->execute();
But the execute-Function expects the Observer Model, and how can i set the order id manually for testing the function?
magento2 event-observer sales-order sales
add a comment |
i have a working Observer on the event sales_order_save_after.
The Observer looks like this:
namespace CompanyExportOrderObserver;
use MagentoFrameworkEventObserverInterface;
class Observer implements ObserverInterface
protected $connector; public function __construct()
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
$orderId = $order->getId();
$customerId = $order->getCustomerId();
// do something
How am i able to call this Observer manually for testing? I don´t really want to create orders again and again. Idea is something like this:
$model = $objectManager->create('CompanyExportOrderObserverObserver');
$model->execute();
But the execute-Function expects the Observer Model, and how can i set the order id manually for testing the function?
magento2 event-observer sales-order sales
i have a working Observer on the event sales_order_save_after.
The Observer looks like this:
namespace CompanyExportOrderObserver;
use MagentoFrameworkEventObserverInterface;
class Observer implements ObserverInterface
protected $connector; public function __construct()
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
$orderId = $order->getId();
$customerId = $order->getCustomerId();
// do something
How am i able to call this Observer manually for testing? I don´t really want to create orders again and again. Idea is something like this:
$model = $objectManager->create('CompanyExportOrderObserverObserver');
$model->execute();
But the execute-Function expects the Observer Model, and how can i set the order id manually for testing the function?
magento2 event-observer sales-order sales
magento2 event-observer sales-order sales
edited Jun 13 at 5:34
Ahmed Zameer
5311
5311
asked Jun 12 at 14:33
LucoLuco
61
61
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Simply create one test order and try to change status of the same order everytime. This will trigger the event sales_order_save_after
$orderId = 1;
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesModelOrder') ->load($orderId);
$orderState = "holded";
$order->setState($orderState)->setStatus("holded");
$order->save();
New contributor
add a comment |
Try following way:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
/** @var MagentoSalesModelOrder $order */
$order = $objectManager->create('MagentoSalesModelOrder')->load(1884);
$eventManager = $objectManager->create('MagentoFrameworkEventManagerInterface');
$eventManager->dispatch('sales_order_save_after', ['order' => $order]);
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%2f278138%2fmagento-2-how-to-call-sales-order-save-after-observer-manually-for-testing%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
Simply create one test order and try to change status of the same order everytime. This will trigger the event sales_order_save_after
$orderId = 1;
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesModelOrder') ->load($orderId);
$orderState = "holded";
$order->setState($orderState)->setStatus("holded");
$order->save();
New contributor
add a comment |
Simply create one test order and try to change status of the same order everytime. This will trigger the event sales_order_save_after
$orderId = 1;
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesModelOrder') ->load($orderId);
$orderState = "holded";
$order->setState($orderState)->setStatus("holded");
$order->save();
New contributor
add a comment |
Simply create one test order and try to change status of the same order everytime. This will trigger the event sales_order_save_after
$orderId = 1;
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesModelOrder') ->load($orderId);
$orderState = "holded";
$order->setState($orderState)->setStatus("holded");
$order->save();
New contributor
Simply create one test order and try to change status of the same order everytime. This will trigger the event sales_order_save_after
$orderId = 1;
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesModelOrder') ->load($orderId);
$orderState = "holded";
$order->setState($orderState)->setStatus("holded");
$order->save();
New contributor
New contributor
answered Jun 12 at 15:58
Abdul PathanAbdul Pathan
1066
1066
New contributor
New contributor
add a comment |
add a comment |
Try following way:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
/** @var MagentoSalesModelOrder $order */
$order = $objectManager->create('MagentoSalesModelOrder')->load(1884);
$eventManager = $objectManager->create('MagentoFrameworkEventManagerInterface');
$eventManager->dispatch('sales_order_save_after', ['order' => $order]);
add a comment |
Try following way:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
/** @var MagentoSalesModelOrder $order */
$order = $objectManager->create('MagentoSalesModelOrder')->load(1884);
$eventManager = $objectManager->create('MagentoFrameworkEventManagerInterface');
$eventManager->dispatch('sales_order_save_after', ['order' => $order]);
add a comment |
Try following way:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
/** @var MagentoSalesModelOrder $order */
$order = $objectManager->create('MagentoSalesModelOrder')->load(1884);
$eventManager = $objectManager->create('MagentoFrameworkEventManagerInterface');
$eventManager->dispatch('sales_order_save_after', ['order' => $order]);
Try following way:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
/** @var MagentoSalesModelOrder $order */
$order = $objectManager->create('MagentoSalesModelOrder')->load(1884);
$eventManager = $objectManager->create('MagentoFrameworkEventManagerInterface');
$eventManager->dispatch('sales_order_save_after', ['order' => $order]);
answered Jun 12 at 16:53
Sohel RanaSohel Rana
24.5k34765
24.5k34765
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');
);
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%2f278138%2fmagento-2-how-to-call-sales-order-save-after-observer-manually-for-testing%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