magento reindex code example

Example 1: magento 2 reindex

php bin/magento indexer:reindex

Example 2: magento shell reindex

php -f shell/indexer.php reindexall

php shell/indexer.php --reindex catalog_product_attribute
php shell/indexer.php --reindex catalog_product_price
php shell/indexer.php --reindex catalog_url
php shell/indexer.php --reindex catalog_product_flat
php shell/indexer.php --reindex catalog_category_flat
php shell/indexer.php --reindex catalog_category_product
php shell/indexer.php --reindex catalogsearch_fulltext
php shell/indexer.php --reindex cataloginventory_stock
php shell/indexer.php --reindex tag_summary

Example 3: magento 2 reindex command line

bin/magento indexer:reindex

Example 4: set indexer mode command line magento 2

bin/magento indexer:set-mode {realtime|schedule} [indexer]

Example 5: set indexer on sheduled magento 2

bin/magento indexer:set-mode schedule indexername