I have line of code which schedule full or partial reindex cron job.

using Trigger::REINDEX_SCOPE_PARTIAL and Trigger::REINDEX_SCOPE_FULL parameter.

public function restoreIndexers($reindex = false, $indexers = null, $threshold = null)
    foreach ($this->prepareCodesForReindex($indexers) as $code) {
        $previousMode = $this->indexerModes[$code] ?? null;

        if (\is_null($previousMode)) {

        try {
            /** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
            $indexer = $this->getIndexerByCode($code);
            $currentMode = $indexer->isScheduled();
            $this->indexerModes[$code] = null;

            if (\is_array($reindex)) {
                $this->scheduleReindex($code, Trigger::REINDEX_SCOPE_PARTIAL, $reindex, $threshold);
            } elseif ($reindex) {
                $this->scheduleReindex($code, Trigger::REINDEX_SCOPE_FULL);
        } catch (\Exception $e) {
            $this->logger->critical($e, [
                'indexer' => $code,
                'previous_mode' => $previousMode ? 'on schedule' : 'on save',
                'current_mode' => isset($currentMode) ? ($currentMode ? 'on schedule' : 'on save') : 'unset',

I need to call mview reindexer using this function. I don't know how can I achieve this. Trigger::REINDEX_SCOPE_MVIEW, and need to add option code under Trigger class. but I am not aware how I can call MVIEW reindexer under scheduleReindex function.

I know very little about this MVIEW reindexer. Can anyone please provide a suggestion?

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.