重新索引只是用Magento编程改变了产品


Re-index just programmatically changed products with Magento

我的Magento商店中有超过130.000件产品。即使我安装了Dn'D Patch Index URL(顺便说一下,这节省了很多时间,例如:只需10分钟的重新索引,而不是大约4小时),当我只是通过我的PHP文件添加或更改两个产品时,通过Magento后端接口重新索引所有内容需要花费很多时间。

是否有可能为添加/更改的产品重新索引所有内容(搜索,价格,库存等)?我用Magmi - DataPump工具添加/更改它们。我的PHP代码是这样的:

$in=array();
$in[]= 'magmi';
$in[]= 'magmi/inc';
$in[]= 'magmi/integration/inc';
$in[]= 'magmi/engines';
$inpath="";
foreach ($in as $i){
    $inpath .= $i .':';
}
$inpath .= '.';
set_include_path($inpath);
require_once("magmi_datapump.php");    // call Datapump
$dp=Magmi_DataPumpFactory::getDataPumpInstance("productimport");
$dp->beginImportSession("default","create");        // default- name of profile ,  create - we want to create and update items
$row = 0;
$handle = fopen("data.csv", "r");
while (($item = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $row++;
    if($row > 0 && $row < 135000){
    $newProductData = array(
            'name'          => (string) $item[1]." ".$item[3],        // name
            'sku'           => (string) $item[1],        // sku     
            'price'         => (real) $item[4],             // price
            'store'         => 'admin',            
            'description'   => (string) $item[2]."'n".$item[3]."'nHerstellerteilenummer: ".$item[1],        // full description
            'short_description' => (string) $item[2]."'n".$item[3]."'nHerstellerteilenummer: ".$item[1],    // short description
            'category_ids'    => '4',                // ID of categories
            'tax_class_id'  => '1',                    // tax class id (check your ids)
            'manufacturer'    => (string) $item[2],        // manufacturer
            'attribute_set' => 'Default',
            'weight'        => (string) "0",
            'use_config_manage_stock'   => 0
    );
    $newProductData['image']='+'.(string) '/media/catalog/product/placeholder/high/'.$item[2].'.png';        // + show picture, - dont show picture
    $newProductData['small_image']='+'.(string) '/media/catalog/product/placeholder/small/'.$item[2].'.png';            // small img
    $newProductData['thumbnail']='+'.(string) '/media/catalog/product/placeholder/thumb/'.$item[2].'.png';            // thumbnail
    $dp->ingest($newProductData);
    print_r($newProductData);
    echo "PRODUCT NR: " . $row;
    echo '' . ' mem:'.memory_get_usage() .  " ... Done! <br />'n";            //memory usage check
    $newProductData=null;    //clear memory
    unset($newProductData); //clear memory
    }
}
unset($item);
$dp->endImportSession();

你的意思是在表上重新创建MySQL索引吗?如果是这样,就没有必要这样做。索引是动态维护的。