10
10
use Magento \Backend \App \Action ;
11
11
use Magento \Backend \Model \View \Result \ForwardFactory ;
12
12
use Magento \Framework \View \Result \PageFactory ;
13
+ use Magento \Framework \App \ObjectManager ;
13
14
use Magento \Framework \Controller \Result \RawFactory ;
14
15
use Magento \Sales \Controller \Adminhtml \Order \Create as CreateAction ;
16
+ use Magento \Store \Model \StoreManagerInterface ;
15
17
16
18
class LoadBlock extends CreateAction implements HttpPostActionInterface, HttpGetActionInterface
17
19
{
@@ -20,21 +22,28 @@ class LoadBlock extends CreateAction implements HttpPostActionInterface, HttpGet
20
22
*/
21
23
protected $ resultRawFactory ;
22
24
25
+ /**
26
+ * @var StoreManagerInterface
27
+ */
28
+ private $ storeManager ;
29
+
23
30
/**
24
31
* @param Action\Context $context
25
32
* @param \Magento\Catalog\Helper\Product $productHelper
26
33
* @param \Magento\Framework\Escaper $escaper
27
34
* @param PageFactory $resultPageFactory
28
35
* @param ForwardFactory $resultForwardFactory
29
36
* @param RawFactory $resultRawFactory
37
+ * @param StoreManagerInterface|null $storeManager
30
38
*/
31
39
public function __construct (
32
40
Action \Context $ context ,
33
41
\Magento \Catalog \Helper \Product $ productHelper ,
34
42
\Magento \Framework \Escaper $ escaper ,
35
43
PageFactory $ resultPageFactory ,
36
44
ForwardFactory $ resultForwardFactory ,
37
- RawFactory $ resultRawFactory
45
+ RawFactory $ resultRawFactory ,
46
+ StoreManagerInterface $ storeManager = null
38
47
) {
39
48
$ this ->resultRawFactory = $ resultRawFactory ;
40
49
parent ::__construct (
@@ -44,6 +53,8 @@ public function __construct(
44
53
$ resultPageFactory ,
45
54
$ resultForwardFactory
46
55
);
56
+ $ this ->storeManager = $ storeManager ?: ObjectManager::getInstance ()
57
+ ->get (StoreManagerInterface::class);
47
58
}
48
59
49
60
/**
@@ -54,6 +65,9 @@ public function __construct(
54
65
public function execute ()
55
66
{
56
67
$ request = $ this ->getRequest ();
68
+ if ($ request ->getParam ('store_id ' ) !== 'false ' ) {
69
+ $ this ->storeManager ->setCurrentStore ($ request ->getParam ('store_id ' ));
70
+ }
57
71
try {
58
72
$ this ->_initSession ()->_processData ();
59
73
} catch (\Magento \Framework \Exception \LocalizedException $ e ) {
0 commit comments