示例#1
0
 /**
  * add all module items to search index
  * @return int
  */
 function addContentToSearch()
 {
     global $db, $router;
     $count = 0;
     $model = new $this->basemodel_name(null, false, false);
     $content = $db->selectArrays($model->tablename);
     foreach ($content as $cnt) {
         $origid = $cnt['id'];
         unset($cnt['id']);
         // get the location data for this content
         if (isset($cnt['location_data'])) {
             $loc = expUnserialize($cnt['location_data']);
         }
         $src = isset($loc->src) ? $loc->src : null;
         //build the search record and save it.
         $search_record = new search($cnt, false, false);
         $search_record->original_id = $origid;
         $search_record->posted = empty($cnt['created_at']) ? null : $cnt['created_at'];
         $link = str_replace(URL_FULL, '', makeLink(array('controller' => $this->baseclassname, 'action' => 'show', 'id' => $origid, 'src' => $src)));
         //	        if (empty($search_record->title)) $search_record->title = 'Untitled';
         $search_record->view_link = $link;
         $search_record->ref_module = $this->classname;
         $search_record->category = $this->searchName();
         $search_record->ref_type = $this->searchCategory();
         $search_record->save();
         $count += 1;
     }
     return $count;
 }
示例#2
0
 function addContentToSearch()
 {
     global $db, $router;
     $model = new $this->basemodel_name();
     $total = $db->countObjects($model->table);
     $count = 1;
     for ($i = 0; $i < $total; $i += 100) {
         $orderby = 'id LIMIT ' . ($i + 1) . ', 100';
         $content = $db->selectArrays($model->table, 'parent_id=0', $orderby);
         foreach ($content as $cnt) {
             $origid = $cnt['id'];
             $prod = new product($cnt['id']);
             unset($cnt['id']);
             //$cnt['title'] = $cnt['title'].' - SKU# '.$cnt['model'];
             $cnt['title'] = (isset($prod->expFile['mainimage'][0]) ? '<img src="' . URL_FULL . 'thumb.php?id=' . $prod->expFile['mainimage'][0]->id . '&w=40&h=40&zc=1" style="float:left;margin-right:5px;" />' : '') . $cnt['title'] . (!empty($cnt['model']) ? ' - SKU#: ' . $cnt['model'] : '');
             $search_record = new search($cnt, false, false);
             $search_record->posted = empty($cnt['created_at']) ? null : $cnt['created_at'];
             $search_record->view_link = $router->makeLink(array('controller' => $this->baseclassname, 'action' => 'showByTitle', 'title' => $cnt['sef_url']));
             $search_record->ref_type = $this->basemodel_name;
             $search_record->ref_module = 'store';
             $search_record->category = 'Products';
             $search_record->original_id = $origid;
             //$search_record->location_data = serialize($this->loc);
             $search_record->save();
             $count += 1;
         }
     }
     return $count;
 }