Ejemplo n.º 1
0
 public function actionSearch()
 {
     $model = new Offers('searchLive');
     $results = $model->liveSearch();
     /*	echo '<a href="'.$result->url.'">';
      			echo '<img src="search_images/'.$result->img.'" alt="" />';
      			
      			$name = $result->name;
      			if(strlen($name) > 35) { 
      				$name = substr($name, 0, 35) . "...";
      			}	         			
      			echo '<span class="searchheading">'.$name.'</span>';
      			
      			$description = $result->desc;
      			if(strlen($description) > 80) { 
      				$description = substr($description, 0, 80) . "...";
      			}
      			
      			echo '<span>'.$description.'</span></a>';
      		}*/
     if (@$_GET['ajax']) {
         //$dataProvider=new CActiveDataProvider('Product');
         $offers = array();
         $offers_ids = array();
         $html = "";
         foreach ($results->getData() as $result) {
             $html .= '<a href="' . $this->createUrl('offers/view', array('slug' => $result->slug)) . '">';
             //$html .= '<img src="search_images/'.$result->img.'" alt="" />';
             $html .= '<span class="searchheading">' . $result->title . '</span>';
             //$html .= '<span>'.$result->description.'</span></a>';
             /*$offers[] = array(
             				//'value'=>$result->title.' savings 50%',
             				'label'=> $result->title.' - average savings: '.EBaseHelper::makePercentage($result->regular_price, $result->our_price).'%',
             				'url'  => $this->createUrl('offers/view', array('slug'=>$result->slug)),
             				'id'   => $result->id,
             		);*/
         }
         echo $html;
         //echo CJSON::encode($offers);
         //echo 'suggestions:'.json_encode($products).',';
         //echo 'data:'.json_encode($product_ids);
         exit;
     }
     $this->render('search', array('offers' => $results));
 }