public function index($Product) { $Indexer = new IndexProduct($Product->id); $Indexer->index(); }
/** * Rebuild the Shopp product search index * * @api * @since 1.3 * * @return void **/ function shopp_rebuild_search_index() { global $wpdb; new ContentParser(); $set = 10; // Process 10 at a time $index_table = ShoppDatabaseObject::tablename(ContentIndex::$table); $total = sDB::query("SELECT count(*) AS products,now() as start FROM {$wpdb->posts} WHERE post_type='" . ShoppProduct::$posttype . "'"); if (empty($total->products)) { false; } set_time_limit(0); // Prevent timeouts $indexed = 0; do_action_ref_array('shopp_rebuild_search_index_init', array($indexed, $total->products, $total->start)); for ($i = 0; $i * $set < $total->products; $i++) { // Outer loop to support buffering $products = sDB::query("SELECT ID FROM {$wpdb->posts} WHERE post_type='" . ShoppProduct::$posttype . "' LIMIT " . $i * $set . ",{$set}", 'array', 'col', 'ID'); foreach ($products as $id) { $Indexer = new IndexProduct($id); $Indexer->index(); $indexed++; do_action_ref_array('shopp_rebuild_search_index_progress', array($indexed, $total->products, $total->start)); } } do_action_ref_array('shopp_rebuild_search_index_completed', array($indexed, $total->products, $total->start)); return true; }
function rebuild_search_index () { check_admin_referer('wp_ajax_ecart_rebuild_search_index'); $db = DB::get(); require(ECART_MODEL_PATH."/Search.php"); new ContentParser(); $set = 10; $product_table = DatabaseObject::tablename(Product::$table); $index_table = DatabaseObject::tablename(ContentIndex::$table); $total = $db->query("SELECT count(id) AS products,now() as start FROM $product_table"); if (empty($total->products)) die('-1'); $Settings = &EcartSettings(); $Settings->save('searchindex_build',mktimestamp($total->start)); $indexed = 0; for ($i = 0; $i*$set < $total->products; $i++) { $row = $db->query("SELECT id FROM $product_table LIMIT ".($i*$set).",$set",AS_ARRAY); foreach ($row as $index => $product) { $Indexer = new IndexProduct($product->id); $Indexer->index(); $indexed++; } } echo "1"; exit(); }