Event when order created from backendExecute custom Javascript code in Frontend/Admin on sales_order_place_after eventgetting order details from sales_order_save_commit_after eventEvent to trigger when admin Hold an order500 when trying to create order on the backendEvent to use when order comment is postCan not called my CreateController while edit an order from backendMagento 2: How to override newsletter Subscriber modelMagento2 - plugin / event after invoice is createdmagento simple popup when create order from adminError creating new order from Backend
Do beef farmed pastures net remove carbon emissions?
What is a "soap"?
My cat is a houdini
What kind of liquid can be seen 'leaking' from the upper surface of the wing of a Boeing 737-800?
Clarification on Integrability
Why did Saruman lie?
Swap on SSD in 2019?
Are there really no countries that protect Freedom of Speech as the United States does?
Corroded Metal vs Magical Armor, should it melt it?
Help, I cannot decide when to start the story
Should I email my professor about a recommendation letter if he has offered me a job?
Why is Python 2.7 still the default Python version in Ubuntu?
PhD advisor lost funding, need advice
Can a bald person be a Nazir?
Boss wants me to ignore a software API license prohibiting mass download
How can I communicate my issues with a potential date's pushy behavior?
How was the murder committed?
In which case does the Security misconfiguration vulnerability apply to?
What is the farthest a camera can see?
Symbol: Put a smile symbol under a plus
What is the hottest thing in the universe?
Is this n-speak?
What can Amex do if I cancel their card after using the sign up bonus miles?
Word for an event that will likely never happen again
Event when order created from backend
Execute custom Javascript code in Frontend/Admin on sales_order_place_after eventgetting order details from sales_order_save_commit_after eventEvent to trigger when admin Hold an order500 when trying to create order on the backendEvent to use when order comment is postCan not called my CreateController while edit an order from backendMagento 2: How to override newsletter Subscriber modelMagento2 - plugin / event after invoice is createdmagento simple popup when create order from adminError creating new order from Backend
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've used sales_order_place_after
to get order id after order placed from backend but it doesnt return order id. Not sure what's missing here.
Here's my observer
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getOrder();
echo $orderId = $order->getId(); exit;
Above code executed but if it doesnt print order id.
Any suggestions for this ? For all those who are curious I need to store order data after order plaed into custom table.
magento2 event-observer admin-order-create
add a comment |
I've used sales_order_place_after
to get order id after order placed from backend but it doesnt return order id. Not sure what's missing here.
Here's my observer
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getOrder();
echo $orderId = $order->getId(); exit;
Above code executed but if it doesnt print order id.
Any suggestions for this ? For all those who are curious I need to store order data after order plaed into custom table.
magento2 event-observer admin-order-create
make sure you place events.xml under etc/adminhtml
– MSA
Aug 2 at 9:57
have you solved your problem?
– Ketan Borada
Aug 10 at 8:50
Yes I was able to solve issue.
– Vivek
2 days ago
add a comment |
I've used sales_order_place_after
to get order id after order placed from backend but it doesnt return order id. Not sure what's missing here.
Here's my observer
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getOrder();
echo $orderId = $order->getId(); exit;
Above code executed but if it doesnt print order id.
Any suggestions for this ? For all those who are curious I need to store order data after order plaed into custom table.
magento2 event-observer admin-order-create
I've used sales_order_place_after
to get order id after order placed from backend but it doesnt return order id. Not sure what's missing here.
Here's my observer
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getOrder();
echo $orderId = $order->getId(); exit;
Above code executed but if it doesnt print order id.
Any suggestions for this ? For all those who are curious I need to store order data after order plaed into custom table.
magento2 event-observer admin-order-create
magento2 event-observer admin-order-create
edited Aug 2 at 9:58
Limbani Himanshu
3321 silver badge9 bronze badges
3321 silver badge9 bronze badges
asked Aug 2 at 9:46
VivekVivek
1,9991 gold badge9 silver badges38 bronze badges
1,9991 gold badge9 silver badges38 bronze badges
make sure you place events.xml under etc/adminhtml
– MSA
Aug 2 at 9:57
have you solved your problem?
– Ketan Borada
Aug 10 at 8:50
Yes I was able to solve issue.
– Vivek
2 days ago
add a comment |
make sure you place events.xml under etc/adminhtml
– MSA
Aug 2 at 9:57
have you solved your problem?
– Ketan Borada
Aug 10 at 8:50
Yes I was able to solve issue.
– Vivek
2 days ago
make sure you place events.xml under etc/adminhtml
– MSA
Aug 2 at 9:57
make sure you place events.xml under etc/adminhtml
– MSA
Aug 2 at 9:57
have you solved your problem?
– Ketan Borada
Aug 10 at 8:50
have you solved your problem?
– Ketan Borada
Aug 10 at 8:50
Yes I was able to solve issue.
– Vivek
2 days ago
Yes I was able to solve issue.
– Vivek
2 days ago
add a comment |
2 Answers
2
active
oldest
votes
You need to just change your code like this.
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
echo $orderId = $order->getId();
exit;
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:38
add a comment |
add observer only for admin appcodeVendorModuleetcadminhtmlevents.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_place_after">
<observer name="load_custom_handler" instance="VendorModuleObserverGetOrder" />
</event>
</config>
add observer file appcodeVendorModuleObserverGetOrder.php
<?php
namespace VendorModuleObserver;
use MagentoFrameworkEventObserverInterface;
class GetOrder implements ObserverInterface
protected $orderFactory;
public function __construct(MagentoSalesModelOrder $orderFactory)
$this->orderFactory = $orderFactory;
public function execute(MagentoFrameworkEventObserver $observer)
$orderIds = $observer->getEvent()->getOrderIds();
$orderId= $orderIds[0]; //Do your logic here
$order = $this->orderFactory->load($orderId);
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:37
i've updated my answer
– Ketan Borada
Aug 2 at 10:58
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%2f284206%2fevent-when-order-created-from-backend%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 need to just change your code like this.
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
echo $orderId = $order->getId();
exit;
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:38
add a comment |
You need to just change your code like this.
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
echo $orderId = $order->getId();
exit;
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:38
add a comment |
You need to just change your code like this.
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
echo $orderId = $order->getId();
exit;
You need to just change your code like this.
public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
echo $orderId = $order->getId();
exit;
answered Aug 2 at 10:13
Dhiren VasoyaDhiren Vasoya
4,9305 gold badges20 silver badges47 bronze badges
4,9305 gold badges20 silver badges47 bronze badges
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:38
add a comment |
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:38
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:38
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:38
add a comment |
add observer only for admin appcodeVendorModuleetcadminhtmlevents.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_place_after">
<observer name="load_custom_handler" instance="VendorModuleObserverGetOrder" />
</event>
</config>
add observer file appcodeVendorModuleObserverGetOrder.php
<?php
namespace VendorModuleObserver;
use MagentoFrameworkEventObserverInterface;
class GetOrder implements ObserverInterface
protected $orderFactory;
public function __construct(MagentoSalesModelOrder $orderFactory)
$this->orderFactory = $orderFactory;
public function execute(MagentoFrameworkEventObserver $observer)
$orderIds = $observer->getEvent()->getOrderIds();
$orderId= $orderIds[0]; //Do your logic here
$order = $this->orderFactory->load($orderId);
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:37
i've updated my answer
– Ketan Borada
Aug 2 at 10:58
add a comment |
add observer only for admin appcodeVendorModuleetcadminhtmlevents.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_place_after">
<observer name="load_custom_handler" instance="VendorModuleObserverGetOrder" />
</event>
</config>
add observer file appcodeVendorModuleObserverGetOrder.php
<?php
namespace VendorModuleObserver;
use MagentoFrameworkEventObserverInterface;
class GetOrder implements ObserverInterface
protected $orderFactory;
public function __construct(MagentoSalesModelOrder $orderFactory)
$this->orderFactory = $orderFactory;
public function execute(MagentoFrameworkEventObserver $observer)
$orderIds = $observer->getEvent()->getOrderIds();
$orderId= $orderIds[0]; //Do your logic here
$order = $this->orderFactory->load($orderId);
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:37
i've updated my answer
– Ketan Borada
Aug 2 at 10:58
add a comment |
add observer only for admin appcodeVendorModuleetcadminhtmlevents.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_place_after">
<observer name="load_custom_handler" instance="VendorModuleObserverGetOrder" />
</event>
</config>
add observer file appcodeVendorModuleObserverGetOrder.php
<?php
namespace VendorModuleObserver;
use MagentoFrameworkEventObserverInterface;
class GetOrder implements ObserverInterface
protected $orderFactory;
public function __construct(MagentoSalesModelOrder $orderFactory)
$this->orderFactory = $orderFactory;
public function execute(MagentoFrameworkEventObserver $observer)
$orderIds = $observer->getEvent()->getOrderIds();
$orderId= $orderIds[0]; //Do your logic here
$order = $this->orderFactory->load($orderId);
add observer only for admin appcodeVendorModuleetcadminhtmlevents.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_place_after">
<observer name="load_custom_handler" instance="VendorModuleObserverGetOrder" />
</event>
</config>
add observer file appcodeVendorModuleObserverGetOrder.php
<?php
namespace VendorModuleObserver;
use MagentoFrameworkEventObserverInterface;
class GetOrder implements ObserverInterface
protected $orderFactory;
public function __construct(MagentoSalesModelOrder $orderFactory)
$this->orderFactory = $orderFactory;
public function execute(MagentoFrameworkEventObserver $observer)
$orderIds = $observer->getEvent()->getOrderIds();
$orderId= $orderIds[0]; //Do your logic here
$order = $this->orderFactory->load($orderId);
edited Aug 2 at 10:58
answered Aug 2 at 10:11
Ketan BoradaKetan Borada
1,00913 silver badges41 bronze badges
1,00913 silver badges41 bronze badges
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:37
i've updated my answer
– Ketan Borada
Aug 2 at 10:58
add a comment |
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:37
i've updated my answer
– Ketan Borada
Aug 2 at 10:58
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:37
Its not working cant able to get order id error is "An ID is needed. Set the ID and try again."
– Vivek
Aug 2 at 10:37
i've updated my answer
– Ketan Borada
Aug 2 at 10:58
i've updated my answer
– Ketan Borada
Aug 2 at 10:58
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%2f284206%2fevent-when-order-created-from-backend%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
make sure you place events.xml under etc/adminhtml
– MSA
Aug 2 at 9:57
have you solved your problem?
– Ketan Borada
Aug 10 at 8:50
Yes I was able to solve issue.
– Vivek
2 days ago