| 
	本教程演示了如何通过在 magento 迷你搜索类别添加搜索。您可能会在 Magento Connect 上搜索的结果,你会发现在 magento 商务,将帮助您搜索您与特定类别的存储区中是没有自由的扩展。但是你可以做如下所示: 
	第一次在form.mini.phtml中创建下拉列表中的所有类别 
	<select name="category" id="category_search_field"> 
	<option value="">-- Any Category --</option> 
	<?php foreach ($catalog->getStoreCategories() as $_category): ?> 
	<?php if($_category->hasChildren()): ?> 
	<option class="parent-cat" value="<?php echo $_category->getId(); ?>"><?php echo $_category->getName();?></option> 
	<?php foreach ($_category->getChildren() as $subcategory): 
	if($subcategory->getIsActive()) : ?> 
	<option value="<?php echo $subcategory->getId(); ?>"<?php echo ($this->getRequest()->getQuery('category') == $subcategory->getId() ? ' selected="selected"': "") ?>><?php echo $subcategory->getName(); ?></option> 
	<?php endif; endforeach; ?> 
	<?php elseif($_category->getIsActive()): ?> 
	<option value="<?php echo $_category->getId(); ?>"><?php echo $_category->getName();?></option> 
	<?php endif; ?> 
	<?php endforeach ?> 
	</select> 
	现在转到应用程序/代码/核心/法师/CatalogSearch/助手和打开Data.php并添加以下代码: 
	public function getStoreCategories() 
	{ 
	$helper = Mage::helper('catalog/category'); 
	return $helper->getStoreCategories(); 
	} 
	public function getSelectedCategory() 
	{ 
	$catid = (int)addslashes($_REQUEST['category']);  
	$cat=""; 
	if($catid>1) 
	$cat = Mage::getModel('catalog/category')->load($catid);  
	return $cat;  
	} 
	现在转到应用程序/代码/核心/法师/CatalogSearch/模型和打开 Layer.php 
	替换 
	public function prepareProductCollection($collection) 
	{ 
	$collection 
	->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) 
	->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText()) 
	->setStore(Mage::app()->getStore()) 
	->addMinimalPrice() 
	->addFinalPrice() 
	->addTaxPercents() 
	->addStoreFilter() 
	->addUrlRewrite(); 
	Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); 
	Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); 
	return $this; 
	} 
	与 
	public function prepareProductCollection($collection) 
	{ 
	if(Mage::helper('catalogsearch')->getSelectedCategory()!="") 
	{ 
	$collection 
	->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) 
	->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText()) 
	->setStore(Mage::app()->getStore()) 
	->addMinimalPrice() 
	->addFinalPrice() 
	->addTaxPercents() 
	->addStoreFilter() 
	->addCategoryFilter(Mage::helper('catalogsearch')->getSelectedCategory()) 
	->addUrlRewrite(); 
	} 
	else 
	{ 
	$collection 
	->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) 
	->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText()) 
	->setStore(Mage::app()->getStore()) 
	->addMinimalPrice() 
	->addFinalPrice() 
	->addTaxPercents() 
	->addStoreFilter()  
	->addUrlRewrite(); 
	}  
	Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); 
	Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); 
	return $this; 
	} 
	保存并享受。(责任编辑:最模板) | 



 shopex家天下模板
							人气:1661
							shopex家天下模板
							人气:1661
						 中英俄多语言代购国内商
							人气:908
							中英俄多语言代购国内商
							人气:908
						 仿趣玩shopex模板
							人气:795
							仿趣玩shopex模板
							人气:795
						 dedecms汽车公司黑简模板
							人气:696
							dedecms汽车公司黑简模板
							人气:696
						 英文卖包包衣服商城|ecs
							人气:5353
							英文卖包包衣服商城|ecs
							人气:5353
						 深蓝色asp中英繁三语外贸
							人气:506
							深蓝色asp中英繁三语外贸
							人气:506