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();