1010use Magento \Backend \App \Action ;
1111use Magento \Backend \Model \View \Result \ForwardFactory ;
1212use Magento \Framework \View \Result \PageFactory ;
13+ use Magento \Framework \App \ObjectManager ;
1314use Magento \Framework \Controller \Result \RawFactory ;
1415use Magento \Sales \Controller \Adminhtml \Order \Create as CreateAction ;
16+ use Magento \Store \Model \StoreManagerInterface ;
1517
1618class LoadBlock extends CreateAction implements HttpPostActionInterface, HttpGetActionInterface
1719{
@@ -20,21 +22,28 @@ class LoadBlock extends CreateAction implements HttpPostActionInterface, HttpGet
2022 */
2123 protected $ resultRawFactory ;
2224
25+ /**
26+ * @var StoreManagerInterface
27+ */
28+ private $ storeManager ;
29+
2330 /**
2431 * @param Action\Context $context
2532 * @param \Magento\Catalog\Helper\Product $productHelper
2633 * @param \Magento\Framework\Escaper $escaper
2734 * @param PageFactory $resultPageFactory
2835 * @param ForwardFactory $resultForwardFactory
2936 * @param RawFactory $resultRawFactory
37+ * @param StoreManagerInterface|null $storeManager
3038 */
3139 public function __construct (
3240 Action \Context $ context ,
3341 \Magento \Catalog \Helper \Product $ productHelper ,
3442 \Magento \Framework \Escaper $ escaper ,
3543 PageFactory $ resultPageFactory ,
3644 ForwardFactory $ resultForwardFactory ,
37- RawFactory $ resultRawFactory
45+ RawFactory $ resultRawFactory ,
46+ StoreManagerInterface $ storeManager = null
3847 ) {
3948 $ this ->resultRawFactory = $ resultRawFactory ;
4049 parent ::__construct (
@@ -44,6 +53,8 @@ public function __construct(
4453 $ resultPageFactory ,
4554 $ resultForwardFactory
4655 );
56+ $ this ->storeManager = $ storeManager ?: ObjectManager::getInstance ()
57+ ->get (StoreManagerInterface::class);
4758 }
4859
4960 /**
@@ -54,6 +65,9 @@ public function __construct(
5465 public function execute ()
5566 {
5667 $ request = $ this ->getRequest ();
68+ if ($ request ->getParam ('store_id ' ) !== 'false ' ) {
69+ $ this ->storeManager ->setCurrentStore ($ request ->getParam ('store_id ' ));
70+ }
5771 try {
5872 $ this ->_initSession ()->_processData ();
5973 } catch (\Magento \Framework \Exception \LocalizedException $ e ) {
0 commit comments