Magento 2 : How To Pass Data From Observer to Phtml FileHow to get manufacturer attribute value on Checkout success page?Pass jQuery value to Observer in Magento 2Pass data from observer to blockPass the values to rest api from magento2 checkout pageHow to get last ordered product details in Magento 2.2?How to save custom form field value from payment form in magento 2Magento 2 getting wrong order and order id when select ship to multiple addressMagento 2 checkout sessionNot able to get post data from observer : M2How to customize order succes page url and add some order details
Does inertia keep a rotating object rotating forever, or something else?
Random piece of plastic
Improve quality of image bars
Intel 8080-based home computers
Interviewing with an unmentioned 9 months of sick leave taken during a job
Is passive Investigation essentially truesight against illusions?
Why does FFmpeg choose 10+20+20 ms instead of an even 16 ms for 60 fps GIF images?
How to have a continuous player experience in a setting that's likely to favor TPKs?
Coverting list of string into integers and reshaping the original list
How to remove the first colon ':' from a timestamp?
Does the Intel 8085 CPU use real memory addresses?
How could an animal "smell" carbon monoxide?
A scene of Jimmy diversity
Is it okay for a chapter's POV to shift as it progresses?
Is straight-up writing someone's opinions telling?
What are the first usages of "thong" as a wearable item of clothing, both on the feet and on the waist?
How possible is a successful landing just with 1 wing?
Create Array from list of indices/values
Vienna To Graz By Rail
Get node ID or URL in Twig on field level
How to find abandoned railways in Google Maps?
What are the basics of commands in Minecraft Java Edition?
How would you say "Sorry, that was a mistake on my part"?
Is this artwork (used in a video game) real?
Magento 2 : How To Pass Data From Observer to Phtml File
How to get manufacturer attribute value on Checkout success page?Pass jQuery value to Observer in Magento 2Pass data from observer to blockPass the values to rest api from magento2 checkout pageHow to get last ordered product details in Magento 2.2?How to save custom form field value from payment form in magento 2Magento 2 getting wrong order and order id when select ship to multiple addressMagento 2 checkout sessionNot able to get post data from observer : M2How to customize order succes page url and add some order details
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am getting order id from order success event, I want to pass order into phtml page.
I tried with checkout session but I did not get order id in phtml page.
anyone can help me regarding this.
i am getting order from bellow code
$order_ids = $observer->getEvent()->getOrderIds()[0];
$order = $this->orderRepository->get($order_ids);
$orderId = $order->getIncrementId();
set session and now getting session value in phtml page
$observer_session = $objectManager->get('MagentoFrameworkSessionSessionManagerInterface');
$order = $observer_session->getValue();
magento2 orders event-observer phtml
add a comment |
I am getting order id from order success event, I want to pass order into phtml page.
I tried with checkout session but I did not get order id in phtml page.
anyone can help me regarding this.
i am getting order from bellow code
$order_ids = $observer->getEvent()->getOrderIds()[0];
$order = $this->orderRepository->get($order_ids);
$orderId = $order->getIncrementId();
set session and now getting session value in phtml page
$observer_session = $objectManager->get('MagentoFrameworkSessionSessionManagerInterface');
$order = $observer_session->getValue();
magento2 orders event-observer phtml
In which page you are trying to pass data
– Prashant Valanda
Jun 23 '18 at 10:20
custom template file
– Sarvesh Tiwari
Jun 23 '18 at 10:20
in phtml file i have written code for product information and call this template under email template file.
– Sarvesh Tiwari
Jun 23 '18 at 10:21
A custom template file is not a page. Can you state which page(s) or layout handle(s) you are trying to access the data on?
– Shawn Abramson
Jun 24 '18 at 5:22
i got solutions
– Sarvesh Tiwari
Jun 24 '18 at 7:34
add a comment |
I am getting order id from order success event, I want to pass order into phtml page.
I tried with checkout session but I did not get order id in phtml page.
anyone can help me regarding this.
i am getting order from bellow code
$order_ids = $observer->getEvent()->getOrderIds()[0];
$order = $this->orderRepository->get($order_ids);
$orderId = $order->getIncrementId();
set session and now getting session value in phtml page
$observer_session = $objectManager->get('MagentoFrameworkSessionSessionManagerInterface');
$order = $observer_session->getValue();
magento2 orders event-observer phtml
I am getting order id from order success event, I want to pass order into phtml page.
I tried with checkout session but I did not get order id in phtml page.
anyone can help me regarding this.
i am getting order from bellow code
$order_ids = $observer->getEvent()->getOrderIds()[0];
$order = $this->orderRepository->get($order_ids);
$orderId = $order->getIncrementId();
set session and now getting session value in phtml page
$observer_session = $objectManager->get('MagentoFrameworkSessionSessionManagerInterface');
$order = $observer_session->getValue();
magento2 orders event-observer phtml
magento2 orders event-observer phtml
edited Jun 23 '18 at 10:49
Sarvesh Tiwari
asked Jun 23 '18 at 10:18
Sarvesh TiwariSarvesh Tiwari
4284 silver badges22 bronze badges
4284 silver badges22 bronze badges
In which page you are trying to pass data
– Prashant Valanda
Jun 23 '18 at 10:20
custom template file
– Sarvesh Tiwari
Jun 23 '18 at 10:20
in phtml file i have written code for product information and call this template under email template file.
– Sarvesh Tiwari
Jun 23 '18 at 10:21
A custom template file is not a page. Can you state which page(s) or layout handle(s) you are trying to access the data on?
– Shawn Abramson
Jun 24 '18 at 5:22
i got solutions
– Sarvesh Tiwari
Jun 24 '18 at 7:34
add a comment |
In which page you are trying to pass data
– Prashant Valanda
Jun 23 '18 at 10:20
custom template file
– Sarvesh Tiwari
Jun 23 '18 at 10:20
in phtml file i have written code for product information and call this template under email template file.
– Sarvesh Tiwari
Jun 23 '18 at 10:21
A custom template file is not a page. Can you state which page(s) or layout handle(s) you are trying to access the data on?
– Shawn Abramson
Jun 24 '18 at 5:22
i got solutions
– Sarvesh Tiwari
Jun 24 '18 at 7:34
In which page you are trying to pass data
– Prashant Valanda
Jun 23 '18 at 10:20
In which page you are trying to pass data
– Prashant Valanda
Jun 23 '18 at 10:20
custom template file
– Sarvesh Tiwari
Jun 23 '18 at 10:20
custom template file
– Sarvesh Tiwari
Jun 23 '18 at 10:20
in phtml file i have written code for product information and call this template under email template file.
– Sarvesh Tiwari
Jun 23 '18 at 10:21
in phtml file i have written code for product information and call this template under email template file.
– Sarvesh Tiwari
Jun 23 '18 at 10:21
A custom template file is not a page. Can you state which page(s) or layout handle(s) you are trying to access the data on?
– Shawn Abramson
Jun 24 '18 at 5:22
A custom template file is not a page. Can you state which page(s) or layout handle(s) you are trying to access the data on?
– Shawn Abramson
Jun 24 '18 at 5:22
i got solutions
– Sarvesh Tiwari
Jun 24 '18 at 7:34
i got solutions
– Sarvesh Tiwari
Jun 24 '18 at 7:34
add a comment |
1 Answer
1
active
oldest
votes
You need to do like this.
From your observer, set the order value into custom session variable.
On phtml file, get those value from session variable.
Here are the demo code.
protected $_coreSession;
public function __construct(
-----
MagentoFrameworkSessionSessionManagerInterface $coreSession
)
$this->_coreSession = $coreSession;
----
public function setValue()
$this->_coreSession->start();
$this->_coreSession->setMessage('YOUR_CUSTOM_VALUE');
public function getValue()
$this->_coreSession->start();
return $this->_coreSession->getMessage();
public function unSetValue()
$this->_coreSession->start();
return $this->_coreSession->unsMessage();
i have set order id with session $data['order']= $order->getIncrementId(); and call in template $orderId = this->getData('order');. but its not working for me
– Sarvesh Tiwari
Jun 23 '18 at 10:24
I am talking about magento core session.
– Dhiren Vasoya
Jun 23 '18 at 10:24
can you help me how ..
– Sarvesh Tiwari
Jun 23 '18 at 10:25
I update my answer with code. Kindly check. And if it help, please accept as soluiton, so it will help other in community as well.
– Dhiren Vasoya
Jun 23 '18 at 10:27
you can get the value using objectmanaget into phtml file.
– Dhiren Vasoya
Jun 23 '18 at 10:30
|
show 7 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%2f231123%2fmagento-2-how-to-pass-data-from-observer-to-phtml-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to do like this.
From your observer, set the order value into custom session variable.
On phtml file, get those value from session variable.
Here are the demo code.
protected $_coreSession;
public function __construct(
-----
MagentoFrameworkSessionSessionManagerInterface $coreSession
)
$this->_coreSession = $coreSession;
----
public function setValue()
$this->_coreSession->start();
$this->_coreSession->setMessage('YOUR_CUSTOM_VALUE');
public function getValue()
$this->_coreSession->start();
return $this->_coreSession->getMessage();
public function unSetValue()
$this->_coreSession->start();
return $this->_coreSession->unsMessage();
i have set order id with session $data['order']= $order->getIncrementId(); and call in template $orderId = this->getData('order');. but its not working for me
– Sarvesh Tiwari
Jun 23 '18 at 10:24
I am talking about magento core session.
– Dhiren Vasoya
Jun 23 '18 at 10:24
can you help me how ..
– Sarvesh Tiwari
Jun 23 '18 at 10:25
I update my answer with code. Kindly check. And if it help, please accept as soluiton, so it will help other in community as well.
– Dhiren Vasoya
Jun 23 '18 at 10:27
you can get the value using objectmanaget into phtml file.
– Dhiren Vasoya
Jun 23 '18 at 10:30
|
show 7 more comments
You need to do like this.
From your observer, set the order value into custom session variable.
On phtml file, get those value from session variable.
Here are the demo code.
protected $_coreSession;
public function __construct(
-----
MagentoFrameworkSessionSessionManagerInterface $coreSession
)
$this->_coreSession = $coreSession;
----
public function setValue()
$this->_coreSession->start();
$this->_coreSession->setMessage('YOUR_CUSTOM_VALUE');
public function getValue()
$this->_coreSession->start();
return $this->_coreSession->getMessage();
public function unSetValue()
$this->_coreSession->start();
return $this->_coreSession->unsMessage();
i have set order id with session $data['order']= $order->getIncrementId(); and call in template $orderId = this->getData('order');. but its not working for me
– Sarvesh Tiwari
Jun 23 '18 at 10:24
I am talking about magento core session.
– Dhiren Vasoya
Jun 23 '18 at 10:24
can you help me how ..
– Sarvesh Tiwari
Jun 23 '18 at 10:25
I update my answer with code. Kindly check. And if it help, please accept as soluiton, so it will help other in community as well.
– Dhiren Vasoya
Jun 23 '18 at 10:27
you can get the value using objectmanaget into phtml file.
– Dhiren Vasoya
Jun 23 '18 at 10:30
|
show 7 more comments
You need to do like this.
From your observer, set the order value into custom session variable.
On phtml file, get those value from session variable.
Here are the demo code.
protected $_coreSession;
public function __construct(
-----
MagentoFrameworkSessionSessionManagerInterface $coreSession
)
$this->_coreSession = $coreSession;
----
public function setValue()
$this->_coreSession->start();
$this->_coreSession->setMessage('YOUR_CUSTOM_VALUE');
public function getValue()
$this->_coreSession->start();
return $this->_coreSession->getMessage();
public function unSetValue()
$this->_coreSession->start();
return $this->_coreSession->unsMessage();
You need to do like this.
From your observer, set the order value into custom session variable.
On phtml file, get those value from session variable.
Here are the demo code.
protected $_coreSession;
public function __construct(
-----
MagentoFrameworkSessionSessionManagerInterface $coreSession
)
$this->_coreSession = $coreSession;
----
public function setValue()
$this->_coreSession->start();
$this->_coreSession->setMessage('YOUR_CUSTOM_VALUE');
public function getValue()
$this->_coreSession->start();
return $this->_coreSession->getMessage();
public function unSetValue()
$this->_coreSession->start();
return $this->_coreSession->unsMessage();
edited Jun 23 '18 at 10:26
answered Jun 23 '18 at 10:22
Dhiren VasoyaDhiren Vasoya
4,8805 gold badges19 silver badges47 bronze badges
4,8805 gold badges19 silver badges47 bronze badges
i have set order id with session $data['order']= $order->getIncrementId(); and call in template $orderId = this->getData('order');. but its not working for me
– Sarvesh Tiwari
Jun 23 '18 at 10:24
I am talking about magento core session.
– Dhiren Vasoya
Jun 23 '18 at 10:24
can you help me how ..
– Sarvesh Tiwari
Jun 23 '18 at 10:25
I update my answer with code. Kindly check. And if it help, please accept as soluiton, so it will help other in community as well.
– Dhiren Vasoya
Jun 23 '18 at 10:27
you can get the value using objectmanaget into phtml file.
– Dhiren Vasoya
Jun 23 '18 at 10:30
|
show 7 more comments
i have set order id with session $data['order']= $order->getIncrementId(); and call in template $orderId = this->getData('order');. but its not working for me
– Sarvesh Tiwari
Jun 23 '18 at 10:24
I am talking about magento core session.
– Dhiren Vasoya
Jun 23 '18 at 10:24
can you help me how ..
– Sarvesh Tiwari
Jun 23 '18 at 10:25
I update my answer with code. Kindly check. And if it help, please accept as soluiton, so it will help other in community as well.
– Dhiren Vasoya
Jun 23 '18 at 10:27
you can get the value using objectmanaget into phtml file.
– Dhiren Vasoya
Jun 23 '18 at 10:30
i have set order id with session $data['order']= $order->getIncrementId(); and call in template $orderId = this->getData('order');. but its not working for me
– Sarvesh Tiwari
Jun 23 '18 at 10:24
i have set order id with session $data['order']= $order->getIncrementId(); and call in template $orderId = this->getData('order');. but its not working for me
– Sarvesh Tiwari
Jun 23 '18 at 10:24
I am talking about magento core session.
– Dhiren Vasoya
Jun 23 '18 at 10:24
I am talking about magento core session.
– Dhiren Vasoya
Jun 23 '18 at 10:24
can you help me how ..
– Sarvesh Tiwari
Jun 23 '18 at 10:25
can you help me how ..
– Sarvesh Tiwari
Jun 23 '18 at 10:25
I update my answer with code. Kindly check. And if it help, please accept as soluiton, so it will help other in community as well.
– Dhiren Vasoya
Jun 23 '18 at 10:27
I update my answer with code. Kindly check. And if it help, please accept as soluiton, so it will help other in community as well.
– Dhiren Vasoya
Jun 23 '18 at 10:27
you can get the value using objectmanaget into phtml file.
– Dhiren Vasoya
Jun 23 '18 at 10:30
you can get the value using objectmanaget into phtml file.
– Dhiren Vasoya
Jun 23 '18 at 10:30
|
show 7 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%2f231123%2fmagento-2-how-to-pass-data-from-observer-to-phtml-file%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
In which page you are trying to pass data
– Prashant Valanda
Jun 23 '18 at 10:20
custom template file
– Sarvesh Tiwari
Jun 23 '18 at 10:20
in phtml file i have written code for product information and call this template under email template file.
– Sarvesh Tiwari
Jun 23 '18 at 10:21
A custom template file is not a page. Can you state which page(s) or layout handle(s) you are trying to access the data on?
– Shawn Abramson
Jun 24 '18 at 5:22
i got solutions
– Sarvesh Tiwari
Jun 24 '18 at 7:34