1

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]."\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();
John Brunner
  • 2,842
  • 11
  • 44
  • 85

1 Answers1

0

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.

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • but when i add products they are not visible with search, and when i change prices of products these changes are just visible on the product-page itself (not on the category page for example). i have to re-index everything manually in order to make the changes visible (or to make the new products visible) – John Brunner Sep 16 '15 at 08:49
  • Please provide `SHOW CREATE TABLE`. – Rick James Sep 16 '15 at 12:28