#!/usr/bin/php -q 1)){ $fh = fopen($prodCount, 'r'); $total = fread($fh,filesize($prodCount)) + 1; fclose($fh); } else { $fh = fopen($prodCount, 'w') or die("can't open file"); $tmpIDs = Mage::getModel('catalog/product')->getCollection()->getAllIds(); $total = $tmpIDs[sizeof($tmpIDs)-1]; //-1 Accounts for 0 in array. fwrite($fh, $total); fclose($fh); } /*## End CLI Version*/ } //REMOVED SESSION OFFERING TO AVOID PEOPLE ACCIDENTLY TURNING IT ON if($total == NULL){ throw new Exception("Total Wasn't Captured"); } /* End Count Products */ echo("\n$total\n"); $countFile = "cm_cnt"; $count = null; $store = Mage::app()->getStore($STOREID); //Create a count file if we dont have one if((file_exists($countFile))&&(filesize($countFile)>1)){ $fh = fopen($countFile, 'r'); $count = fread($fh,filesize($countFile)) + 1; fclose($fh); if((int)$count == 0) $count = 1; } else { $fh = fopen($countFile, 'w') or die("can't open file"); $count = 0; if((int)$count == 0) $count = 1; fwrite($fh, $count); fclose($fh); } //If we havent started counting yet clear cache. if($count < 2) { Mage::app()->cleanCache(); //Clear the database flag from any previous "normal" indexes that failed $flag = Mage::getModel('catalogindex/catalog_index_flag')->loadSelf(); if ($flag->getState() == Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_RUNNING) $flag->delete(); } $max = ($count+$HM); $sx = Mage::app()->getStore($STOREID); ob_start(); echo "start loop (max = $max) (count = $count)"; for($i = $count; $i <= $max; $i++) { ob_end_flush(); ob_start(); if($i == $total) { echo "

Completed


"; @unlink($prodCount); @unlink($countFile); exit(1); } Mage::getSingleton('catalogindex/indexer')->plainReindex($i, null, $sx); echo("\n #Record $i#CURRENT MEMRY USAGE = ".memory_get_usage().";\n"); //UPDATE SCREEN //Write where were up to $fh = fopen($countFile, 'w') or die("can't open file"); fwrite($fh, $i); fclose($fh); ob_flush(); flush(); } }catch(Exception $e){ echo"

ERROR: $e


"; exit(1);} #EOF ?>