2

I have to get order id in admin edit order?

I have tried to get order id from quote but the order creating new so that I don't fetch order id. Is there any way to get order id in admin edit order?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$quote = $objectManager->create('Magento\Backend\Model\Session');
$quoteData = $quote->getQuote()->getData();

But I can't fetch any order detail.

9
  • can you add more description and also what you tried so far. it will be very helpful. Commented Apr 27, 2018 at 5:31
  • can you please check it @QaisarSatti
    – Moin Malek
    Commented Apr 27, 2018 at 5:43
  • can you share your edit order url? Commented Apr 27, 2018 at 5:44
  • domain.com/admin/sales/order_create/index/key/aa701fe990ca5037ae2250eb8d57843dbb9d4be3ad71898c4442f95b5bf1bf12/
    – Moin Malek
    Commented Apr 27, 2018 at 5:51
  • this is new order create page not order edit can you share what you want to do here with order. For getting the order id you need event for that Commented Apr 27, 2018 at 5:53

2 Answers 2

3

Magento using the quote session for that following code is magento is using to get order increment id.

protected $_sessionQuote; 
public function __construct(
        \Magento\Backend\Model\Session\Quote $sessionQuote,

    ) {


        $this->_sessionQuote = $sessionQuote;
    }


$this->_sessionQuote->getOrder()->getIncrementId();

So here is an update code for you make things clear.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$quote = $objectManager->create('\Magento\Backend\Model\Session\Quote');
echo  $quote->getOrder()->getIncrementId();
1
  • Absolutely right answer Thanks for helping me out. you saved my time. +1 vote
    – Moin Malek
    Commented Apr 27, 2018 at 6:38
0

Accepted answer didn't solve my problem, In case If you're using plugin for class

Magento\Framework\App\Action\AbstractAction

than you can get order id in params

$controller->getRequest()->getParam('order_id');

In any plugin you can get it by

$this->request->getParams();

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.