66
77namespace Magento \Indexer \Setup ;
88
9+ use Magento \Framework \App \ObjectManager ;
910use Magento \Framework \Encryption \Encryptor ;
1011use Magento \Framework \Encryption \EncryptorInterface ;
1112use Magento \Framework \Indexer \StateInterface ;
1213use Magento \Framework \Json \EncoderInterface ;
1314use Magento \Framework \Setup \InstallSchemaInterface ;
1415use Magento \Framework \Setup \ModuleContextInterface ;
1516use Magento \Framework \Setup \SchemaSetupInterface ;
17+ use Magento \Framework \Indexer \IndexerInterfaceFactory ;
1618use Magento \Framework \Indexer \ConfigInterface ;
1719use Magento \Indexer \Model \Indexer \State ;
1820use Magento \Indexer \Model \Indexer \StateFactory ;
@@ -51,6 +53,11 @@ class Recurring implements InstallSchemaInterface
5153 */
5254 private $ stateFactory ;
5355
56+ /**
57+ * @var IndexerInterfaceFactory
58+ */
59+ private $ indexerFactory ;
60+
5461 /**
5562 * Init
5663 *
@@ -59,19 +66,22 @@ class Recurring implements InstallSchemaInterface
5966 * @param ConfigInterface $config
6067 * @param EncryptorInterface $encryptor
6168 * @param EncoderInterface $encoder
69+ * @param IndexerInterfaceFactory|null $indexerFactory
6270 */
6371 public function __construct (
6472 CollectionFactory $ statesFactory ,
6573 StateFactory $ stateFactory ,
6674 ConfigInterface $ config ,
6775 EncryptorInterface $ encryptor ,
68- EncoderInterface $ encoder
76+ EncoderInterface $ encoder ,
77+ IndexerInterfaceFactory $ indexerFactory = null
6978 ) {
7079 $ this ->statesFactory = $ statesFactory ;
7180 $ this ->stateFactory = $ stateFactory ;
7281 $ this ->config = $ config ;
7382 $ this ->encryptor = $ encryptor ;
7483 $ this ->encoder = $ encoder ;
84+ $ this ->indexerFactory = $ indexerFactory ?: ObjectManager::getInstance ()->get (IndexerInterfaceFactory::class);
7585 }
7686
7787 /**
@@ -107,6 +117,11 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
107117 $ state ->setStatus (StateInterface::STATUS_INVALID );
108118 $ state ->save ();
109119 }
120+
121+ $ indexer = $ this ->indexerFactory ->create ()->load ($ indexerId );
122+ if ($ indexer ->isScheduled ()) {
123+ $ indexer ->getView ()->unsubscribe ()->subscribe ();
124+ }
110125 }
111126 }
112127}
0 commit comments