在本教程中,我们将讨论“ 命令行系列”中通过命令行进行的重新索引/索引器用法。如您所知,在Magento 2中,它们在中添加了许多命令。这可能很难解决,让我解释一下它的更多细节。bin/magento
让我们显示所有重新索引用法
php bin/magento indexer --help
它将显示以下内容:
indexer
indexer:info Shows allowed Indexers
indexer:reindex Reindexes Data
indexer:reset Resets indexer status to invalid
indexer:set-mode Sets index mode type
indexer:show-mode Shows Index Mode
indexer:status Shows status of Indexer
索引器命令行
通过以下命令检查索引器状态
php bin/magento indexer:info
我们将得到结果:
design_config_grid Design Config Grid
customer_grid Customer Grid
catalog_category_product Category Products
catalog_product_category Product Categories
catalog_product_price Product Price
catalog_product_attribute Product EAV
catalogsearch_fulltext Catalog Search
cataloginventory_stock Stock
catalogrule_rule Catalog Rule Product
catalogrule_product Catalog Product Rule
如何重新索引数据
php bin/magento indexer:reindex
如何将索引器状态重置为无效
php bin/magento indexer:reset
如何显示索引模式
php bin/magento indexer:show-mode
结果:
$ php bin/magento indexer:show-mode
Design Config Grid: Update on Save
Customer Grid: Update on Save
Category Products: Update on Save
Product Categories: Update on Save
Product Price: Update on Save
Product EAV: Update on Save
Catalog Search: Update on Save
Stock: Update on Save
Catalog Rule Product: Update on Save
Catalog Product Rule: Update on Save
如何设置索引模式类型
php bin/magento indexer:set-mode {realtime|schedule} [indexer]
例如:
magento indexer:set-mode schedule catalog_category_product catalog_product_category