2012-05-08 35 views

回答

0

link去Magento網站應該有所幫助。您需要從目錄創建屬性。然後查看前端屬性(目錄>屬性)下的設置。

+0

感謝您的鏈接,雖然它不是我要找的。該鏈接描述瞭如何將分層導航添加到網站(我知道該怎麼做)。我的問題是關於將分層導航專門添加到**高級搜索**(這似乎忽略了通用設置)。 – mas

5

對此沒有快速解決方案。標準搜索和高級搜索使用兩種不同的方法進行搜索。

如果您比較catalogsearch.xml中的佈局,您會發現對於catalogsearch_advanced_result,塊catalogsearch/layer不包括在內。如果從catalogsearch_result_index複製塊定義並將根模板更改爲3columns.phtml,則會引發各種錯誤。 >配置 - - >目錄 - >目錄搜索 -

1

在我的1.6.2分層資產淨值爲0(零)設置爲
系統後,出現了>應用分層導航,如果搜索結果小於

0

簡單catalogsearch.xml預先搜索結果區域幫助我在我的EE網站上看到它,但我沒有檢查它在CE版本。

<block type="catalogsearch/layer" name="catalogsearch.leftnav" before="-" template="catalog/layer/view.phtml"/> 

所以我完全左側區域看起來像這樣提前上搜索區域的xml文件:

<reference name="left"> 
     <block type="catalog/navigation" name="hello.leftnav" as="hello.leftnav" template="catalog/navigation/hello_left_nav-search.phtml" /> 
     <block type="catalog/layer_view" name="catalog.leftnav" before="-" template="catalog/layer/view.phtml"/> 
    </reference> 

希望它可以幫助別人。

7

下面的補丁將在高級搜索結果中顯示分層導航,並且可以在分層導航中正常工作。 分層導航和搜索結果基於兩個獨立的產品集合進行顯示,其中一個由catalogsearch/Model/Layer.php創建,另一個由catalogsearch/Model/Advanced.php創建。 因此,我們需要覆蓋這些模型的幾個功能,以使高級搜索中的分層導航工作。

1-在您的local.xml下的catalogsearch_advanced_result標籤添加。 catalogsearch /模型/ Layer.php與

public function prepareProductCollection($collection){ 

    if(Mage::helper('catalogsearch')->getQuery()->getQueryText())//for normal search we get the value from query string q=searchtext 
     return parent::prepareProductCollection($collection); 
    else{ 

     $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()); 
     /** 
     * make sure you cross check the $_REQUEST with $attributes 
     */ 
     $attributes = Mage::getSingleton('catalog/product')->getAttributes(); 

     Mage::log(print_r($_REQUEST,1)); 
     foreach($attributes as $attribute){ 
      $attribute_code = $attribute->getAttributeCode(); 
      //Mage::log("--->>". $attribute_code); 
      if($attribute_code == "price")//since i am not using price attribute 
       continue; 

      if (empty($_REQUEST[$attribute_code])){ 
       //Mage::log("nothing found--> $attribute_code"); 
       continue; 
      } 
      if(!empty($_REQUEST[$attribute_code]) && is_array($_REQUEST[$attribute_code])) 
       $collection->addAttributeToFilter($attribute_code, array('in' => $_REQUEST[$attribute_code])); 
      else 
      if(!empty($_REQUEST[$attribute_code])) 
       $collection->addAttributeToFilter($attribute_code, array('like' => "%" . $_REQUEST[$attribute_code] . "%")); 
     } 

     $collection->setStore(Mage::app()->getStore()) 
     ->addMinimalPrice() 
     ->addFinalPrice() 
     ->addTaxPercents() 
     ->addStoreFilter() 
     ->addUrlRewrite(); 

     //Mage::log($collection->getSelect()->__toString()); 

     Mage::getSingleton('catalogsearch/advanced')->prepareProductCollection($collection);  
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); 
     Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); 
    } 

    return $this; 
} 

覆蓋getProductCollection

<reference name="left"> 
     <block type="catalogsearch/layer" name="catalogsearch.leftnav" after="currency" template="catalog/layer/view.phtml"/> 
</reference> 

覆蓋prepareProductCollection功能,具有catalogsearch /模型/ Advanced.php的getSearchCriterias功能

public function getProductCollection(){ 

    if (is_null($this->_productCollection)) { 
     $this->_productCollection = Mage::getResourceModel('catalogsearch/advanced_collection') 
      ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) 
      ->addMinimalPrice() 
      ->addStoreFilter(); 
      Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->_productCollection); 
      Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($this->_productCollection); 

     if(isset($_GET['cat']) && is_numeric($_GET['cat'])) 
      $this->_productCollection->addCategoryFilter(Mage::getModel('catalog/category')->load($_GET['cat']),true); 
    } 
    return $this->_productCollection; 
} 

public function getSearchCriterias() 
{ 
    $search = parent::getSearchCriterias(); 
    /* display category filtering criteria */ 
    if(isset($_GET['cat']) && is_numeric($_GET['cat'])) { 
     $category = Mage::getModel('catalog/category')->load($_GET['cat']); 
     $search[] = array('name'=>'Category','value'=>$category->getName()); 
    } 
    return $search; 
}