In this tutorial I am going to show some of code which will be help full to flush cache and reindexing magento 2 programatically . I have given the code having both dependency injection and through object manager. I have also posted same article for magento 1 reindexing-magento-programmatically .

flush cache and reindexing programatically in magento 2
flush cache and reindexing programatically in magento 2

1. Reindex:
1.1.By CMD:

1.2.Programatically:
1.2.1.By Using DI:

1.2.2.By using OM:

2.Cache flush/Clean:
2.1.CMD:

2.2.Programmatically:
2.2.1.Using DI:

2.2.2.Using OM:

Hope you like this article “flush cache and reindexing programatically in magento 2” and will never to share for others.

flush cache and reindexing programatically in magento 2
The following two tabs change content below.
Jyotiranjan is one of passionate programmer who has been working in magento since 4 years and in the mean time he has developed enormous amount of modules and customization of sites.He loves to write blogs and travel for long journeying.
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *