I am uploading a csv file and reading the content of the file and updating the table to update product Stock, also I need to update the stock to sync in to elastic search and for that I need to run the indexer, so I'm doing that programmatically. Take a look

  protected $_indexerFactory;
  public function __construct(\Magento\Indexer\Model\IndexerFactory $indexerFactory)
     $this->_indexerFactory = $indexerFactory;
  private function reindexAll(){
        $indexerIds = array(

        foreach ($indexerIds as $key=> $indexerId) {
            echo " create index: ".$indexerId."\n";
            $indexer = $this->_indexerFactory->create();


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.