@@ -32,6 +32,11 @@ class RegenerateUrlRewrites extends Command
32
32
*/
33
33
protected $ _storeManager ;
34
34
35
+ /**
36
+ * @var \Magento\Framework\App\State $appState
37
+ */
38
+ protected $ _appState ;
39
+
35
40
/**
36
41
* Constructor of RegenerateUrlRewrites
37
42
*
@@ -42,11 +47,13 @@ class RegenerateUrlRewrites extends Command
42
47
public function __construct (
43
48
\Magento \Framework \App \ResourceConnection $ resource ,
44
49
\Magento \Catalog \Model \ResourceModel \Category \CollectionFactory $ categoryCollectionFactory ,
45
- \Magento \Catalog \Helper \Category $ categoryHelper
50
+ \Magento \Catalog \Helper \Category $ categoryHelper ,
51
+ \Magento \Framework \App \State $ appState
46
52
) {
47
53
$ this ->_resource = $ resource ;
48
54
$ this ->_categoryCollectionFactory = $ categoryCollectionFactory ;
49
55
$ this ->_categoryHelper = $ categoryHelper ;
56
+ $ this ->_appState = $ appState ;
50
57
parent ::__construct ();
51
58
}
52
59
@@ -100,6 +107,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
100
107
101
108
// remove all current url rewrites
102
109
$ this ->removeAllUrlRewrites ($ storesList );
110
+
111
+ $ this ->_appState ->setAreaCode ('adminhtml ' );
103
112
104
113
foreach ($ storesList as $ storeId => $ storeCode ) {
105
114
$ output ->write ("[Store ID: {$ storeId }, Store View code: {$ storeCode }]: " );
0 commit comments