मैंने उन्नत खोज परत नेविगेशन के लिए 3 चरणों का पालन किया है, लेकिन यह काम नहीं कर रहा है। किसी भी विचार / सुझाव या उन्नत खोज में परत नेविगेशन कैसे लागू करें?
1) हमारी लोकल.एक्सएमएल में कैटलॉग सर्च_एडवांटेड_रेल्ट टैग के तहत।
<reference name="left">
<block type="catalogsearch/layer" name="catalogsearch.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
2) कैटलॉग / मॉडल / 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;
}
3) ओवरराइड getProductCollection, getSearchCriterias फ़ंक्शन का कैटलॉग खोज / मॉडल / उन्नत.php के साथ
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;
}