为Interspire Shopping Cart添加产品列表功能

本帖由 nulled2014-01-29 发布。版面名称:Interspire 产品交流

  1. nulled

    nulled 正式会员

    Interspire Shopping Cart添加产品列表功能,可以加快搜索引擎对ISC的产品页收录,可以确保每个页面最多只需经过两次链接爬取就能被搜索引擎抓取到,是一个非常实用的功能。
    demo图如下:
    Interspire-Shopping-Cart-Product-List-Module.jpg

    首先,先修改ISC根目录下的init.php
    在$GLOBALS['RewriteRules']中添加如下代码:


    代码:
    "productlist" => array(
    	"class" => "class.productlist.php",
    	"name" => "ISC_PRODUCTLIST",
    	"global" => "ISC_CLASS_PRODUCTLIST"
    ),
    


    然后再在 includes/classes目录下新建class.productlist.php文件,部分核心代码如下:

    代码:
    //分页
    function ShowTags(){
    
    	$tag=$this->GetTag();//获取首字母或数字
    	$tag=strtolower($tag);
    	$currentPage=$this->GetPage();//获取当前页数
    	$size = 25;
    
    	//这里最好使用memcached缓存查询结果
    	if($tag=="0-9"){
    		$query = "SELECT COUNT(DISTINCT prodname) as total FROM [|PREFIX|]products where prodvisible=1 and ascii(prodname)>48 and ascii(prodname)<57";
    	}
    	elseif($tag=="all"){
    		$query = "SELECT COUNT(DISTINCT prodname) as total FROM [|PREFIX|]products where prodvisible=1 and prodname and ascii(prodname)<48 or ascii(prodname)>57";
    	}
    	else{
    		if(strlen($tag) == 1){
    			$query = "SELECT COUNT(DISTINCT prodname) as total FROM [|PREFIX|]products where prodvisible=1 and prodname like '".addslashes($tag)."%'";
    		}
    		else{
    			$query = "SELECT COUNT(DISTINCT prodname) as total FROM [|PREFIX|]products where prodvisible=1 and prodname and ascii(prodname)<48 or ascii(prodname)>57";
    		}
    	}
    	$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
    	$row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
    	$Num = $row['total'];
    	$numPages = ceil($Num/$size);
    	
    	//...... 略去部分代码 ......
    	
    	//页面内容
    	$start = ($currentPage-1)*$size;
    
    	if($tag=="0-9"){
    		$query = "SELECT * from [|PREFIX|]products where prodvisible=1 and ascii(prodname)>48 and ascii(prodname)<57 ORDER BY prodname ASC";
    	}
    	elseif($tag=="all"){
    		$query = "SELECT * from [|PREFIX|]products WHERE prodvisible=1 AND ascii(prodname)<48 OR ascii(prodname)>57 ORDER BY lower(prodname) ASC";
    	}
    	else{
    		if(strlen($tag) == 1){
    			$query = "SELECT * FROM [|PREFIX|]products WHERE prodname like '".addslashes($tag)."%' ORDER BY lower(prodname) ASC";
    		}
    		else{
    			$query = "SELECT * from [|PREFIX|]products WHERE prodvisible=1 AND ascii(prodname)<48 OR ascii(prodname)>57 ORDER BY lower(prodname) ASC";
    		}
    	}
    	
    	//筛选出指定条数的查询记录
    	$query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start,$size);
    	$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
    	
    	//...... 略去部分代码 ......
    
    	$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("productlist");
    	$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
    }
    


    然后在templates/__master目录下新建相应的模板,即可实现Interspire Shopping Cart添加产品列表功能。祝大家使用愉快~


    本文出自 EvilSec外贸电商圈,非注明转载皆为原创,转载时请注明出处及相应链接。
    原文链接:为Interspire Shopping Cart添加产品列表功能
     
  2. impig33

    impig33 新人

正在加载...