1313use Magento \Framework \Setup \InstallSchemaInterface ;
1414use Magento \Framework \Setup \ModuleContextInterface ;
1515use Magento \Framework \Setup \SchemaSetupInterface ;
16+ use Magento \Framework \Indexer \IndexerInterfaceFactory ;
1617use Magento \Framework \Indexer \ConfigInterface ;
1718use Magento \Indexer \Model \Indexer \State ;
1819use Magento \Indexer \Model \Indexer \StateFactory ;
1920use Magento \Indexer \Model \ResourceModel \Indexer \State \CollectionFactory ;
2021
2122/**
23+ * Indexer recurring setup
24+ *
2225 * @codeCoverageIgnore
2326 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2427 */
@@ -51,6 +54,11 @@ class Recurring implements InstallSchemaInterface
5154 */
5255 private $ stateFactory ;
5356
57+ /**
58+ * @var IndexerInterfaceFactory
59+ */
60+ private $ indexerFactory ;
61+
5462 /**
5563 * Init
5664 *
@@ -59,23 +67,26 @@ class Recurring implements InstallSchemaInterface
5967 * @param ConfigInterface $config
6068 * @param EncryptorInterface $encryptor
6169 * @param EncoderInterface $encoder
70+ * @param IndexerInterfaceFactory $indexerFactory
6271 */
6372 public function __construct (
6473 CollectionFactory $ statesFactory ,
6574 StateFactory $ stateFactory ,
6675 ConfigInterface $ config ,
6776 EncryptorInterface $ encryptor ,
68- EncoderInterface $ encoder
77+ EncoderInterface $ encoder ,
78+ IndexerInterfaceFactory $ indexerFactory
6979 ) {
7080 $ this ->statesFactory = $ statesFactory ;
7181 $ this ->stateFactory = $ stateFactory ;
7282 $ this ->config = $ config ;
7383 $ this ->encryptor = $ encryptor ;
7484 $ this ->encoder = $ encoder ;
85+ $ this ->indexerFactory = $ indexerFactory ;
7586 }
7687
7788 /**
78- * { @inheritdoc}
89+ * @inheritdoc
7990 */
8091 public function install (SchemaSetupInterface $ setup , ModuleContextInterface $ context )
8192 {
@@ -107,6 +118,11 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
107118 $ state ->setStatus (StateInterface::STATUS_INVALID );
108119 $ state ->save ();
109120 }
121+
122+ $ indexer = $ this ->indexerFactory ->create ()->load ($ indexerId );
123+ if ($ indexer ->isScheduled ()) {
124+ $ indexer ->getView ()->unsubscribe ()->subscribe ();
125+ }
110126 }
111127 }
112128}
0 commit comments