使用代码对magento进行reindex

来源:互联网 发布:mac os x 10.13 cdr 编辑:程序博客网 时间:2024/05/22 06:06

在后台System -> Index Management,我们可以手动进行reindex,其实呢,使用代码也是可以方便的进行reindex的。
进入System -> Index Management,假设共有以下项目:
1. Product Attributes
2. Product Prices
3. Catalog URL Rewrites
4. Product Flat Data
5. Category Flat Data
6. Category Products
7. Catalog Search index
8. Tag Aggregation Data
9. Stock Status

如果想对Product Flat Data reindex,按照以下步骤,将load参数设为4,

注:将鼠标移到这些项目上,从url提示可以确认参数值。

$process = Mage::getModel('index/process')->load(4);$process->reindexAll();

如果想对所有项目reindex,请使用以下方式:

for ($i = 1; $i <= 9; $i++) {    $process = Mage::getModel('index/process')->load($i);    $process->reindexAll();}

转载请注明出处!