I have a payment module used in Magento 2 backend order creation.

In Magento 2 the administrator first chooses the store where the order is to be created. However, when reading configuration I always get configuration from store 1. Also using \Magento\Store\Model\StoreManagerInterface I always get store ID 1.

How can I find out which store the order is being created to?


  • Perhaps you will find the the answer for your question here – Siarhey Uchukhlebau Dec 12 '16 at 11:32
  • Nope, tried and getting store id 0. The website selection is different for backend orders. – Tero Lahtinen Dec 12 '16 at 12:29

As you can see in the corresponding controller (Magento\Sales\Controller\Adminhtml\Order\Create) you should use next code to get the requested store id:

$storeId = $this->getRequest()->getParam('store_id');

Or you can get the store_id from the current quote session (just add the Magento\Backend\Model\Session\Quote in di):

/** @var \Magento\Backend\Model\Session\Quote $session */
  • getParam does not work in an observer, $session->getStoreId() does. – Tero Lahtinen Dec 12 '16 at 14:27
  • @TeroLahtinen If my answer has helped you, please accept it. – Siarhey Uchukhlebau Dec 12 '16 at 17:09
  • I have to face this issue still using this class Magento\Store\Model\StoreManagerInterface::store => store->getStore()->getStoreId(); It return 1, when I refresh the page then it return correct selected store id in order create page screen – HaFiz Umer May 27 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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