Ecshop realize commodity Classification tree display classification of goods quantity

Source: Internet
Author: User

Very simple change.

1. Under includes/lib_goods.php
Find these two functions and change them to me.

The code is as follows Copy Code
function Get_categories_tree ($cat _id = 0)
function Get_child_tree ($tree _id = 0)

/**
* Get all the categories of the specified category and the subcategories under that category
*
* @access Public
* @param integer $cat _id category number
* @return Array
*/
function Get_categories_tree ($cat _id = 0)
{
if ($cat _id > 0)
{
$sql = ' SELECT parent_id from '. $GLOBALS [' ECS ']->table (' category '). "WHERE cat_id = ' $cat _id '";
$parent _id = $GLOBALS [' db ']->getone ($sql);
}
Else
{
$parent _id = 0;
}

/*
Determine whether the current classification is all a bottom level category,
If you are removing the bottom level category superior classification,
If you do not take the current category and its sub categories
*/
$sql = ' SELECT count (*) from '. $GLOBALS [' ECS ']->table (' category '). "WHERE parent_id = ' $parent _id ' and is_show = 1";
if ($GLOBALS [' DB ']->getone ($sql) | | $parent _id = = 0)
{
/* Get current classification and its subcategories * *
$sql = ' SELECT cat_id,cat_name, Parent_id,is_show '.
' From '. $GLOBALS [' ECS ']->table (' category ').
"WHERE parent_id = ' $parent _id ' and is_show = 1 ORDER by sort_order ASC, cat_id ASC";

$res = $GLOBALS [' db ']->getall ($sql);

foreach ($res as $row)
{
if ($row [' is_show '])
{
/* Get the total number of merchandise carving Eagle team: QQ284265134 * *
$children = Get_children ($row [' cat_id ']);
$sql = ' SELECT count (*) '. "From". $GLOBALS [' ECS ']->table (' goods '). ' As G '.
' WHERE G.is_on_sale = 1 and G.is_alone_sale = 1 and '.
' G.is_delete = 0 and ('. $children. ' OR '. Get_extension_goods ($children). ') ';
$cat _goods_num= $GLOBALS [' DB ']->getone ($sql);
$cat _arr[$row [' cat_id ']][' goods_num '] = $cat _goods_num = = '? 0: $cat _goods_num;

$cat _arr[$row [' cat_id ']][' id '] = $row [' cat_id '];
$cat _arr[$row [' cat_id ']][' name '] = $row [' Cat_name '];
$cat _arr[$row [' cat_id ']][' url '] = Build_uri (' category ', Array (' CID ' => $row [' cat_id ']), $row [' cat_name ']);

if (Isset ($row [' cat_id '])!= NULL)
{
$cat _arr[$row [' cat_id ']][' cat_id '] = Get_child_tree ($row [' cat_id ']);
}
}
}
}
if (Isset ($cat _arr))
{
return $cat _arr;
}
}

function Get_child_tree ($tree _id = 0)
{
$three _arr = Array ();
$sql = ' SELECT count (*) from '. $GLOBALS [' ECS ']->table (' category '). "WHERE parent_id = ' $tree _id ' and is_show = 1";
if ($GLOBALS [' DB ']->getone ($sql) | | $tree _id = = 0)
{
$child _sql = ' SELECT cat_id, Cat_name, parent_id, Is_show '.
' From '. $GLOBALS [' ECS ']->table (' category ').
"WHERE parent_id = ' $tree _id ' and is_show = 1 ORDER by sort_order ASC, cat_id ASC";
$res = $GLOBALS [' db ']->getall ($child _sql);
foreach ($res as $row)
{
/* Get the total number of merchandise carving Eagle team: QQ284265134 * *
$children = Get_children ($row [' cat_id ']);
$sql = ' SELECT count (*) '. "From". $GLOBALS [' ECS ']->table (' goods '). ' As G '.
' WHERE G.is_on_sale = 1 and G.is_alone_sale = 1 and '.
' G.is_delete = 0 and ('. $children. ' OR '. Get_extension_goods ($children). ') ';
$cat _goods_num= $GLOBALS [' DB ']->getone ($sql);
$three _arr[$row [' cat_id ']][' goods_num '] = $cat _goods_num = = '? 0: $cat _goods_num;

if ($row [' is_show '])

$three _arr[$row [' cat_id ']][' id '] = $row [' cat_id '];
$three _arr[$row [' cat_id ']][' name '] = $row [' Cat_name '];
$three _arr[$row [' cat_id ']][' url '] = Build_uri (' category ', Array (' CID ' => $row [' cat_id ']), $row [' cat_name ']);

if (Isset ($row [' cat_id '])!= NULL)
{
$three _arr[$row [' cat_id ']][' cat_id '] = Get_child_tree ($row [' cat_id ']);

}
}
}
return $three _arr;
}


Library/group_buy.lbi

Note here: The original lefttime.js is defined as a single ID
<font id= "Lefttime" class= "F1" > here loop, ID repeat certain error.
How do we solve this? You can copy a new lefttime.js from the JS folder. Here I named: lefttime1.js; call

The code is as follows Copy Code
: <script type= "Text/javascript" src= "Js/lefttime1.js" ></script>


<meta http-equiv= "Content-type" content= "text/html; CHARSET=GBK ">
<script type= "Text/javascript" src= "Js/lefttime.js" ></script>


<!--{if $group _buy_goods}-->
<div class= "box" style= "border:1px solid #e2e2e2; width:198px; " >
<div class= "box_1" style= "Border:none;" >
<div class= "Boxcenterlist clearfix" >
<!--{foreach from= $group _buy_goods item=goods}-->
<ul class= "Clearfix" style= "position:relative;" >
<li class= "goodsimg" style= "width:190px; height:190px; margin:0px; " ><a style= "margin:0px;width:190px; height:190px "href=" {$goods. URL} "></a></li>
<li style= "Text-align:center; width:200px; Overflow:hidden; font-size:14px; Font-weight:bold; " ><a href= "{$goods. URL}" title= "{$goods. goods_name|escape:html}" >{$goods. short_style_name|escape:html} </a></li>
<li style= "width:100%;" ><font class= "shop_s" >{$goods .last_price}</font></li>
<div class= "Index_group" > Sold <strong>{$goods .vn}</strong> parts </div>
Time Remaining: <span id= "Lefttime" > End time: {$goods .gmt_end_date}</span>
</ul>
<!--{/foreach}-->
</div>

</div>
</div>
<div class= "Blank" ></div>
<!--{/if}-->

<script type= "Text/javascript" >
var gmt_end_time = "{$goods. gmt_end_date|default:0}";
{foreach from= $lang. Goods_js Item=item Key=key}
var {$key} = ' {$item} ';
{/foreach}
var now_time = "{$goods. gmt_now_date|default:0}";
<!--{literal}-->

onload = function ()
{
Try
{
Onload_lefttime ();
}
catch (E)
{}
}
<!--{/literal}-->
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.