2012-05-08 33 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; 
}