I can reindex a specific indexer method by following way in Magento 1.x

$process = Mage::getModel('index/indexer')->getProcessByCode('catalog_product_price');

How to reindex catalog_product_price indexer in Magento 2.x

1 Answer 1


We can try with Magento\Framework\Indexer\IndexerInterfaceFactory.

     * @var \Magento\Framework\Indexer\IndexerInterfaceFactory
    protected $indexerFactory;

     * @param IndexerInterfaceFactory $indexerFactory
    public function __construct(
        \Magento\Framework\Indexer\IndexerInterfaceFactory $indexerFactory,
    ) {
        $this->indexerFactory = $indexerFactory;


     * @param string $indexerId
     * @return \Magento\Framework\Indexer\IndexerInterface
    public function getIndexer($indexerId)
        return $this->indexerFactory->create()->load($indexerId);

    public function executeIndex() {

  • I already have a custruct function: public function __construct( \Magento\Framework\App\Action\Context $context) { return parent::__construct($context); } How to combine it with your construct function? Dec 7, 2016 at 12:57
  • Need to add \Magento\Framework\Indexer\IndexerInterfaceFactory to the current constructor. Dec 7, 2016 at 12:59
  • Will I have to call executeIndex function anywhere or it will be called automatically? Actually I have execute() method and within this function I want to reindex "catalog_product_price". Dec 7, 2016 at 13:06
  • Technically, you can call $this->indexerFactory->create()->load('catalog_product_price')->reindexAll() in the execute method. Dec 7, 2016 at 13:08
  • How can I reindex all indexer method I mean I want to reindex all instead of specific indexer method Dec 7, 2016 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.