2015-09-15 27 views
1

我的Magento商店中有超過130.000種產品。即使我安裝了Dn'D Patch Index URL(這樣可以節省很多時間,例如:只需10分鐘的重新索引,而不是4個小時左右),當我只需要通過Magento後端接口重新索引所有內容時,需要很長時間通過我的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(); 

回答

0

「re index」是指在表上重新創建MySQL索引?如果是這樣,則不需要這樣做。索引是動態維護的。

+0

但是,當我添加產品時,它們在搜索時不可見,當我更改產品的價格時,這些更改僅在產品頁面上顯示(例如不在類別頁面上)。我必須手動重新索引所有內容,以便使更改可見(或使新產品可見) –

+0

請提供'SHOW CREATE TABLE'。 –