6
6
7
7
namespace Magento \Indexer \Setup ;
8
8
9
+ use Magento \Framework \App \ObjectManager ;
9
10
use Magento \Framework \Encryption \Encryptor ;
10
11
use Magento \Framework \Encryption \EncryptorInterface ;
11
12
use Magento \Framework \Indexer \StateInterface ;
12
13
use Magento \Framework \Json \EncoderInterface ;
13
14
use Magento \Framework \Setup \InstallSchemaInterface ;
14
15
use Magento \Framework \Setup \ModuleContextInterface ;
15
16
use Magento \Framework \Setup \SchemaSetupInterface ;
17
+ use Magento \Framework \Indexer \IndexerInterfaceFactory ;
16
18
use Magento \Framework \Indexer \ConfigInterface ;
17
19
use Magento \Indexer \Model \Indexer \State ;
18
20
use Magento \Indexer \Model \Indexer \StateFactory ;
@@ -51,6 +53,11 @@ class Recurring implements InstallSchemaInterface
51
53
*/
52
54
private $ stateFactory ;
53
55
56
+ /**
57
+ * @var IndexerInterfaceFactory
58
+ */
59
+ private $ indexerFactory ;
60
+
54
61
/**
55
62
* Init
56
63
*
@@ -59,19 +66,22 @@ class Recurring implements InstallSchemaInterface
59
66
* @param ConfigInterface $config
60
67
* @param EncryptorInterface $encryptor
61
68
* @param EncoderInterface $encoder
69
+ * @param IndexerInterfaceFactory|null $indexerFactory
62
70
*/
63
71
public function __construct (
64
72
CollectionFactory $ statesFactory ,
65
73
StateFactory $ stateFactory ,
66
74
ConfigInterface $ config ,
67
75
EncryptorInterface $ encryptor ,
68
- EncoderInterface $ encoder
76
+ EncoderInterface $ encoder ,
77
+ IndexerInterfaceFactory $ indexerFactory = null
69
78
) {
70
79
$ this ->statesFactory = $ statesFactory ;
71
80
$ this ->stateFactory = $ stateFactory ;
72
81
$ this ->config = $ config ;
73
82
$ this ->encryptor = $ encryptor ;
74
83
$ this ->encoder = $ encoder ;
84
+ $ this ->indexerFactory = $ indexerFactory ?: ObjectManager::getInstance ()->get (IndexerInterfaceFactory::class);
75
85
}
76
86
77
87
/**
@@ -107,6 +117,11 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
107
117
$ state ->setStatus (StateInterface::STATUS_INVALID );
108
118
$ state ->save ();
109
119
}
120
+
121
+ $ indexer = $ this ->indexerFactory ->create ()->load ($ indexerId );
122
+ if ($ indexer ->isScheduled ()) {
123
+ $ indexer ->getView ()->unsubscribe ()->subscribe ();
124
+ }
110
125
}
111
126
}
112
127
}
0 commit comments