3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Catalog \Controller \Adminhtml ;
7
9
10
+ use Magento \Store \Model \Store ;
11
+
8
12
/**
9
13
* Catalog category controller
10
14
*/
@@ -34,6 +38,22 @@ public function __construct(
34
38
parent ::__construct ($ context );
35
39
}
36
40
41
+ /**
42
+ * Resolve store id
43
+ *
44
+ * Tries to take store id from store HTTP parameter, if can`t find it, try to dig into store_id
45
+ * If param is absent in store_id too, take default one
46
+ * @see Store
47
+ *
48
+ * @return int
49
+ */
50
+ private function resolveStoreId () : int
51
+ {
52
+ $ storeId = $ this ->getRequest ()->getParam ('store ' , false );
53
+ $ storeId = $ storeId === false ? $ this ->getRequest ()->getParam ('store_id ' , Store::DEFAULT_STORE_ID ) : $ storeId ;
54
+ return (int ) $ storeId ;
55
+ }
56
+
37
57
/**
38
58
* Initialize requested category and put it into registry.
39
59
* Root category can be returned, if inappropriate store/category is specified
@@ -44,7 +64,7 @@ public function __construct(
44
64
protected function _initCategory ($ getRootInstead = false )
45
65
{
46
66
$ categoryId = $ this ->resolveCategoryId ();
47
- $ storeId = ( int ) $ this ->getRequest ()-> getParam ( ' store ' );
67
+ $ storeId = $ this ->resolveStoreId ( );
48
68
$ category = $ this ->_objectManager ->create (\Magento \Catalog \Model \Category::class);
49
69
$ category ->setStoreId ($ storeId );
50
70
0 commit comments