13
13
use Magento \Framework \Setup \InstallSchemaInterface ;
14
14
use Magento \Framework \Setup \ModuleContextInterface ;
15
15
use Magento \Framework \Setup \SchemaSetupInterface ;
16
+ use Magento \Framework \Indexer \IndexerInterfaceFactory ;
16
17
use Magento \Framework \Indexer \ConfigInterface ;
17
18
use Magento \Indexer \Model \Indexer \State ;
18
19
use Magento \Indexer \Model \Indexer \StateFactory ;
19
20
use Magento \Indexer \Model \ResourceModel \Indexer \State \CollectionFactory ;
20
21
21
22
/**
23
+ * Indexer recurring setup
24
+ *
22
25
* @codeCoverageIgnore
23
26
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
24
27
*/
@@ -51,6 +54,11 @@ class Recurring implements InstallSchemaInterface
51
54
*/
52
55
private $ stateFactory ;
53
56
57
+ /**
58
+ * @var IndexerInterfaceFactory
59
+ */
60
+ private $ indexerFactory ;
61
+
54
62
/**
55
63
* Init
56
64
*
@@ -59,23 +67,26 @@ class Recurring implements InstallSchemaInterface
59
67
* @param ConfigInterface $config
60
68
* @param EncryptorInterface $encryptor
61
69
* @param EncoderInterface $encoder
70
+ * @param IndexerInterfaceFactory $indexerFactory
62
71
*/
63
72
public function __construct (
64
73
CollectionFactory $ statesFactory ,
65
74
StateFactory $ stateFactory ,
66
75
ConfigInterface $ config ,
67
76
EncryptorInterface $ encryptor ,
68
- EncoderInterface $ encoder
77
+ EncoderInterface $ encoder ,
78
+ IndexerInterfaceFactory $ indexerFactory
69
79
) {
70
80
$ this ->statesFactory = $ statesFactory ;
71
81
$ this ->stateFactory = $ stateFactory ;
72
82
$ this ->config = $ config ;
73
83
$ this ->encryptor = $ encryptor ;
74
84
$ this ->encoder = $ encoder ;
85
+ $ this ->indexerFactory = $ indexerFactory ;
75
86
}
76
87
77
88
/**
78
- * { @inheritdoc}
89
+ * @inheritdoc
79
90
*/
80
91
public function install (SchemaSetupInterface $ setup , ModuleContextInterface $ context )
81
92
{
@@ -107,6 +118,11 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
107
118
$ state ->setStatus (StateInterface::STATUS_INVALID );
108
119
$ state ->save ();
109
120
}
121
+
122
+ $ indexer = $ this ->indexerFactory ->create ()->load ($ indexerId );
123
+ if ($ indexer ->isScheduled ()) {
124
+ $ indexer ->getView ()->unsubscribe ()->subscribe ();
125
+ }
110
126
}
111
127
}
112
128
}
0 commit comments