2012-05-08 35 views

Trả lời

0

Điều này link truy cập trang web Magento sẽ hữu ích. Bạn cần tạo thuộc tính từ Catalogs. Sau đó, xem các cài đặt trong Thuộc tính Frontend (Catalogs> Thuộc tính).

+0

Cảm ơn bạn đã liên kết, mặc dù đó không phải là những gì tôi đang tìm kiếm. Liên kết mô tả cách thêm Điều hướng lớp vào trang web (mà tôi biết cách thực hiện). Câu hỏi của tôi là về việc thêm Điều hướng lớp thành ** Tìm kiếm nâng cao ** cụ thể (dường như bỏ qua các cài đặt chung). – mas

5

Không có giải pháp nhanh cho việc này. Tìm kiếm chuẩn và tìm kiếm nâng cao sử dụng hai phương pháp khác nhau để tìm kiếm.

Nếu bạn so sánh bố cục trong catalogsearch.xml bạn thấy rằng đối với catalogsearch_advanced_result, khối catalogsearch/layer không được bao gồm. Nếu bạn sao chép định nghĩa khối từ catalogsearch_result_index và thay đổi mẫu gốc thành 3columns.phtml các lỗi khác nhau sẽ được ném.

1

Trong 1.6.2 của tôi nav lớp xuất hiện sau khi cài đặt một 0 (Zero) để
System -> Configuration -> Catalogue -> Catalog tìm kiếm -> Apply Layered Navigation nếu kết quả tìm kiếm là ít hơn

0

Simply thêm dòng sau vào catalogsearch.xml kết quả tìm kiếm trước bên trái khu vực đã giúp tôi hiển thị trên trang web EE của mình, tuy nhiên tôi chưa kiểm tra trong phiên bản CE.

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

Vì vậy, khu vực trái đầy đủ của tôi trông như thế này trên diện tích tìm kiếm nâng cao trên file 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> 

Hy vọng nó sẽ giúp những người khác.

7

Bản vá bên dưới sẽ hiển thị điều hướng lớp trong kết quả tìm kiếm nâng cao và sẽ hoạt động tốt với điều hướng lớp. Điều hướng lớp và kết quả tìm kiếm được hiển thị dựa trên hai bộ sưu tập sản phẩm riêng biệt, một được tạo bởi catalogsearch/Model/Layer.php và khác bằng catalogsearch/Model/Advanced.php. Vì vậy, chúng ta cần ghi đè lên một số chức năng của cả hai mô hình này để thực hiện công việc điều hướng lớp trong Tìm kiếm nâng cao.

1- Trong tệp local.xml của bạn dưới catalogsearch_advanced_result thêm thẻ.

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

chức năng Override prepareProductCollection của catalogsearch/mô hình/Layer.php với

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; 
} 

Override getProductCollection, getSearchCriterias chức năng của catalogsearch/mô hình/Advanced.php với

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; 
} 
Các vấn đề liên quan