Get edit order id magento 2 admin
-
08-01-2021 - |
문제
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.
해결책
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();
다른 팁
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.
제휴하지 않습니다 magento.stackexchange