服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > magento教程 >

优化magento属性筛选URL(layer filter)

时间:2015-07-10 00:52来源:未知 作者:最模板 点击:
优化magento属性筛选URL(layer filter) 一:config.xml 重写filter item ?xml version=1.0? config modules More_LayerCatSeo version0.1.0/version /More_LayerCatSeo /modules global models devopencatseo classMore_LayerCatSeo_Model/class re
优化magento属性筛选URL(layer filter)
 
一:config.xml 重写filter item
 
<?xml version="1.0"?>
<config>
<modules>
<More_LayerCatSeo>
<version>0.1.0</version>
</More_LayerCatSeo>
</modules>
<global>
<models>
<devopencatseo>
<class>More_LayerCatSeo_Model</class>
<resourceModel>devopencatseo_resource</resourceModel>
</devopencatseo>
<devopencatseo_resource>
<class>More_LayerCatSeo_Model_Resource</class>
</devopencatseo_resource>
<catalog>
<rewrite>
<layer_filter_item>More_LayerCatSeo_Model_Layer_Filter_Item</layer_filter_item>
</rewrite>
</catalog>
</models>
<helpers>
<devopencatseo>
<class>More_LayerCatSeo_Helper</class>
</devopencatseo>
</helpers>
</global>
</config>
二:实现方法:
 
app/code/local/More/LayerCatSeo/Model/Layer/Filter/
 
 
class More_LayerCatSeo_Model_Layer_Filter_Item extends Mage_Catalog_Model_Layer_Filter_Item
{
/**
* Get filter item url
*
* @return string
*/
public function getUrl()
{
if($this->getFilter()->getRequestVar() == "cat"){
$category_url = Mage::getModel('catalog/category')->load($this->getValue())->getUrl();
$return = $category_url;
$request = Mage::getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true));
if(strpos($request,'?') !== false ){
$query_string = substr($request,strpos($request,'?'));
}
else{
$query_string = '';
}
if(!empty($query_string)){
$return .= $query_string;
}
return $return;
}
else{
$query = array(
$this->getFilter()->getRequestVar()=>$this->getValue(),
Mage::getBlockSingleton('page/html_pager')->getPageVarName() => null // exclude current page from urls
);
return Mage::getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true, '_query'=>$query));
}
}
}
(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------