_beforeToHtml()) {
return $html;
}
$suggestData = $this->getSuggestData();
if (!($count = count($suggestData))) {
return $html;
}
$count--;
$html = '
';
foreach ($suggestData as $index => $item) {
if ($index == 0) {
$item['row_class'] .= ' first';
}
if ($index == $count) {
$item['row_class'] .= ' last';
}
$html .= '- '
. ''.$item['num_of_results'].''.$this->htmlEscape($item['title']).'
';
}
$html.= '
';
return $html;
}
public function getSuggestData()
{
if (!$this->_suggestData) {
$collection = $this->helper('catalogsearch')->getSuggestCollection();
$query = $this->helper('catalogsearch')->getQueryText();
$counter = 0;
$data = array();
foreach ($collection as $item) {
$_data = array(
'title' => $item->getQueryText(),
'row_class' => (++$counter)%2?'odd':'even',
'num_of_results' => $item->getNumResults()
);
if ($item->getQueryText() == $query) {
array_unshift($data, $_data);
}
else {
$data[] = $_data;
}
}
$this->_suggestData = $data;
}
return $this->_suggestData;
}
/*
*
*/
}