有时,你可能会发现,需要通过命令行来重新索引Magento。这可能原因一大堆,例如,如果该索引超时或是通过Web界面没有完成。 Magento包含索引脚本,你可以找到

Shell

文件夹
在这个文件夹,你可以执行一些命令

检查所有索引的状态

php indexer.php --status

应该会输出类似下面:

Product Attributes:            Pending
Product Prices:                Pending
Stock Status:                  Pending
Tag Aggregation Data:          Pending
Default Values:                Pending
Catalog URL Rewrites:          Pending
Product Flat Data:             Require Reindex
Category Flat Data:            Pending
Category Products:             Pending
Catalog Search Index:          Pending

重新索引单个索引

每个索引都有自己的索引键,当magento需要重新索引时就需要引用它,要获得这些键,你可以使用一下命令

php indexer.php --info

你将会得到:

catalog_product_attribute     Product Attributes
catalog_product_price         Product Prices
cataloginventory_stock        Stock Status
tag_summary                   Tag Aggregation Data
mana_db_replicator            Default Values
catalog_url                   Catalog URL Rewrites
catalog_product_flat          Product Flat Data
catalog_category_flat         Category Flat Data
catalog_category_product      Category Products
catalogsearch_fulltext        Catalog Search Index

重新索引单个索引,运行一下命令:

php indexer.php --reindex [Index Option Code]

可以用逗号来分离多个索引

php indexer.php --reindex catalog_product_price,catalog_url,catalog_product_flat

重新刷新所有索引

下面的代码将通过每个索引循环,来重新建立索引

php indexer.php --reindexall