00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_CatalogSearch_Block_Result extends Mage_Core_Block_Template
00036 {
00037
00038
00039
00040
00041
00042 protected $_productCollection;
00043
00044
00045
00046
00047
00048
00049 protected function _getQuery()
00050 {
00051 return $this->helper('catalogSearch')->getQuery();
00052 }
00053
00054
00055
00056
00057
00058
00059 protected function _prepareLayout()
00060 {
00061 $title = $this->__("Search results for: '%s'", $this->helper('catalogSearch')->getEscapedQueryText());
00062
00063
00064 if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
00065 $breadcrumbs->addCrumb('home', array(
00066 'label' => $this->__('Home'),
00067 'title' => $this->__('Go to Home Page'),
00068 'link' => Mage::getBaseUrl()
00069 ))->addCrumb('search', array(
00070 'label' => $title,
00071 'title' => $title
00072 ));
00073 }
00074 $this->getLayout()->getBlock('head')->setTitle($title);
00075
00076 return parent::_prepareLayout();
00077 }
00078
00079
00080
00081
00082
00083
00084 public function getListBlock()
00085 {
00086 return $this->getChild('search_result_list');
00087 }
00088
00089
00090
00091
00092
00093
00094 public function setListOrders() {
00095 $category = Mage::getSingleton('catalog/layer')
00096 ->getCurrentCategory();
00097
00098 $availableOrders = $category->getAvailableSortByOptions();
00099 unset($availableOrders['position']);
00100 $availableOrders = array_merge(array(
00101 'relevance' => $this->__('Relevance')
00102 ), $availableOrders);
00103
00104 $this->getListBlock()
00105 ->setAvailableOrders($availableOrders)
00106 ->setDefaultDirection('desc')
00107 ->setSortBy('relevance');
00108
00109 return $this;
00110 }
00111
00112
00113
00114
00115
00116
00117 public function setListModes() {
00118 $this->getListBlock()
00119 ->setModes(array(
00120 'grid' => $this->__('Grid'),
00121 'list' => $this->__('List'))
00122 );
00123 return $this;
00124 }
00125
00126
00127
00128
00129
00130
00131 public function setListCollection() {
00132 $this->getListBlock()
00133 ->setCollection($this->_getProductCollection());
00134 return $this;
00135 }
00136
00137
00138
00139
00140
00141
00142 public function getProductListHtml()
00143 {
00144 return $this->getChildHtml('search_result_list');
00145 }
00146
00147
00148
00149
00150
00151
00152 protected function _getProductCollection()
00153 {
00154 if (is_null($this->_productCollection)) {
00155 $this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection();
00156 }
00157
00158 return $this->_productCollection;
00159 }
00160
00161
00162
00163
00164
00165
00166 public function getResultCount()
00167 {
00168 if (!$this->getData('result_count')) {
00169 $size = $this->_getProductCollection()->getSize();
00170 $this->_getQuery()->setNumResults($size);
00171 $this->setResultCount($size);
00172 }
00173 return $this->getData('result_count');
00174 }
00175
00176
00177
00178
00179
00180
00181 public function getNoResultText()
00182 {
00183 if (Mage::helper('catalogSearch')->isMinQueryLength()) {
00184 return Mage::helper('catalogSearch')->__('Minimum Search query length is %s', $this->_getQuery()->getMinQueryLenght());
00185 }
00186 return $this->_getData('no_result_text');
00187 }
00188
00189
00190
00191
00192
00193
00194 public function getNoteMessages()
00195 {
00196 return Mage::helper('catalogSearch')->getNoteMessages();
00197 }
00198 }