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 class Mage_CatalogSearch_Block_Advanced_Result extends Mage_Core_Block_Template
00035 {
00036 protected function _prepareLayout()
00037 {
00038 if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
00039 $breadcrumbs->addCrumb('home', array(
00040 'label'=>Mage::helper('catalogsearch')->__('Home'),
00041 'title'=>Mage::helper('catalogsearch')->__('Go to Home Page'),
00042 'link'=>Mage::getBaseUrl()
00043 ))->addCrumb('search', array(
00044 'label'=>Mage::helper('catalogsearch')->__('Catalog Advanced Search'),
00045 'link'=>$this->getUrl('*/*/')
00046 ))->addCrumb('search_result', array(
00047 'label'=>Mage::helper('catalogsearch')->__('Results')
00048 ));
00049 }
00050 return parent::_prepareLayout();
00051 }
00052
00053 public function setListOrders() {
00054 $category = Mage::getSingleton('catalog/layer')
00055 ->getCurrentCategory();
00056
00057
00058 $availableOrders = $category->getAvailableSortByOptions();
00059 unset($availableOrders['position']);
00060
00061 $this->getChild('search_result_list')
00062 ->setAvailableOrders($availableOrders);
00063 }
00064
00065 public function setListModes() {
00066 $this->getChild('search_result_list')
00067 ->setModes(array(
00068 'grid' => Mage::helper('catalogsearch')->__('Grid'),
00069 'list' => Mage::helper('catalogsearch')->__('List'))
00070 );
00071 }
00072
00073 public function setListCollection() {
00074 $this->getChild('search_result_list')
00075 ->setCollection($this->_getProductCollection());
00076 }
00077
00078 protected function _getProductCollection(){
00079 return $this->getSearchModel()->getProductCollection();
00080 }
00081
00082 public function getSearchModel()
00083 {
00084 return Mage::getSingleton('catalogsearch/advanced');
00085 }
00086
00087 public function getResultCount()
00088 {
00089 if (!$this->getData('result_count')) {
00090 $size = $this->getSearchModel()->getProductCollection()->getSize();
00091 $this->setResultCount($size);
00092 }
00093 return $this->getData('result_count');
00094 }
00095
00096 public function getProductListHtml()
00097 {
00098 return $this->getChildHtml('search_result_list');
00099 }
00100
00101 public function getFormUrl()
00102 {
00103 return Mage::getModel('core/url')
00104 ->setQueryParams($this->getRequest()->getQuery())
00105 ->getUrl('*/*/', array('_escape' => true));
00106 }
00107
00108 public function getSearchCriterias()
00109 {
00110 $searchCriterias = $this->getSearchModel()->getSearchCriterias();
00111 $middle = ceil(count($searchCriterias) / 2);
00112 $left = array_slice($searchCriterias, 0, $middle);
00113 $right = array_slice($searchCriterias, $middle);
00114
00115 return array('left'=>$left, 'right'=>$right);
00116 }
00117 }