In the current version of Magento, using indexes is one of the most important key features. Without the correct indexes, we will not be able to use Magento properly.
What do the indexes do, and why are they so important? One of the key elements is to make things run faster. Without indexing, Magento 2 would have to calculate data on the fly. In Magento 2, we will be using the following nine indexes:
adminhtml
backend pages.catalog_product_index_price_*
) and makes the selects (sorting and filtering) much easier.The database table looks as follows:
The control panel of the backend looks like this:
For this recipe, we will use a Droplet created in Chapter 1, Installing Magento 2 on Apache and NGINX, at DigitalOcean, https://www.digitalocean.com/. We will be using NGINX, PHP-FPM, and a Composer-based setup. A working Magento 2 setup is required.
The following are the steps to implement the recipe:
Update on Save: Index tables are updated immediately after the dictionary data is changed
Update by Schedule: Index tables are updated by cron job according to the configured schedule
php bin/magento indexer:info
We now get an overview of all the indexers.
php bin/magento indexer:status
; this will give us an up-to-date status of the current indexes.php bin/magento indexer:show-mode
; this information is related to the Update on Save or Update by Schedule modes.php bin/magento indexer:info realtime customer_grid
Using the mode option realtime (Update on Save) or schedule (Update by Schedule) may set the indexer.
php bin/magento indexer:reindex
This will reindex all the indexers. However, you can also reindex them individually using the following command:
php bin/magento indexer:reindex customer_grid
We can also use the following command:
php bin/magento indexer:reindex customer_grid catalog_category_product etc…
indexer:status
to check whether all the indexers are up to date.Let's recap and find out what we did throughout this recipe. In steps 1 through 7, you learned how to use the bin/magento
indexer.
In step 5, you learned how to check what the current status is of all the indexes. In step 4, we saw how to switch from the realtime Update on Save to the schedule Update on Schedule modes.
In step 6, you learned how to reindex them individually.
18.224.54.136