dtudj42064 2015-09-15 15:40
浏览 45

使用Magento重新编制索引以编程方式更改的产品

I have more than 130.000 products in my Magento store. Even though I installed Dn'D Patch Index URL (which saves a lot of time by the way, e.g.: just 10 minutes of re-indexing instead of around 4 hours) it takes a lot of time to re-index everything via the Magento backend interface when I just add or change two products via my PHP file.

Is it possible to re-index everything (search, prices, stock, etc.) just for the added/changed products? I add/change them with the Magmi - DataPump tool. My PHP code looks like that:

$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]."
".$item[3]."
Herstellerteilenummer: ".$item[1],        // full description
            'short_description' => (string) $item[2]."
".$item[3]."
Herstellerteilenummer: ".$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 />
";            //memory usage check
    $newProductData=null;    //clear memory
    unset($newProductData); //clear memory
    }
}

unset($item);

$dp->endImportSession();
  • 写回答

1条回答 默认 最新

  • duannuo7878 2015-09-15 21:38
    关注

    By "re index" do you mean recreating the MySQL index(es) on the table? If so, there is no need to do such. The indexes are maintained dynamically.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大