- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018
12:46 AM
11-26-2018
12:46 AM
Hi guys , how can i use getLastRealOrder()->getEntityId(); in .phtml file.
can any one guide me ?
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018
01:46 AM
11-26-2018
01:46 AM
You can use this way by Creating Block file,
<?php namespace Rbj\Checkout\Block; class Success extends \Magento\Framework\View\Element\Template { public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Checkout\Model\Session $checkoutSession, array $data = [] ) { $this->checkoutSession = $checkoutSession; parent::__construct($context, $data); public function getLastOrder() { return $this->_checkoutSession->getLastRealOrder()->getEntityId(); } }
Call Block function in a template file,
echo $block->getLastOrder();
Directly template file, Check using below file, I am not sure its working or not,
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); echo $lastOrderId = $objectManager->get('Magento\Checkout\Model\Session')->getLastRealOrder()->getEntityId();
If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial
Magento 2 Blogs/Tutorial
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018
01:26 AM
11-26-2018
01:26 AM
Re: how to use getLastRealOrder()->getEntityId(); in .phtml file magento 2
Hello @bharath553
In which module phtml file you want to call?
Manish Mittal
https://www.manishmittal.com/
https://www.manishmittal.com/
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018
01:46 AM
11-26-2018
01:46 AM
You can use this way by Creating Block file,
<?php namespace Rbj\Checkout\Block; class Success extends \Magento\Framework\View\Element\Template { public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Checkout\Model\Session $checkoutSession, array $data = [] ) { $this->checkoutSession = $checkoutSession; parent::__construct($context, $data); public function getLastOrder() { return $this->_checkoutSession->getLastRealOrder()->getEntityId(); } }
Call Block function in a template file,
echo $block->getLastOrder();
Directly template file, Check using below file, I am not sure its working or not,
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); echo $lastOrderId = $objectManager->get('Magento\Checkout\Model\Session')->getLastRealOrder()->getEntityId();
If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial
Magento 2 Blogs/Tutorial