店铺商品分类增加商品数量统计[TianYan 小技巧讲座07]
2016-07-07 16:48 来源:www.chinab4c.com 作者:ecshop专家
| 功能修改的目的,让店长了解自己每个店铺每个分类都有多少商品,也方便在店铺首页调用。 1. 在商品数据表ecm_gcategory增加 goodscount 字段 类型 int 11 2.my_category.lang.php 语言标签增加 //Tianyan 'goodscount' => '商品', 'newgcount'=> '重计商品', 3. 修改 my_category.index.html 模板增加商品数量列 <div class="wrap"> <div class="eject_btn_two eject_pos3" title="{$lang.gcategory_add}"><b class="ico3" ectype="dialog" dialog_title="{$lang.gcategory_add}" dialog_id="my_category_add" dialog_width="480" uri="index.php?app=my_category&act=add">{$lang.gcategory_add}</b></div> <div class="eject_btn_three eject_pos1" title="{$lang.import}"><b class="ico3"ectype="dialog" dialog_title="{$lang.import}" dialog_id="my_category_import" dialog_width="480" uri="index.php?app=my_category&act=import">{$lang.import}</b></div> <div class="eject_btn_three eject_pos4" title="{$lang.export}"><b class="ico4" <!--{if $charset eq 'utf-8'}-->ectype="dialog" dialog_title="{$lang.export}" dialog_id="my_category_export" dialog_width="480" uri="index.php?app=my_category&act=export" <!--{else}-->onclick="window.location.href='index.php?app=my_category&act=export'"<!--{/if}-->>{$lang.export}</b></div> <div class="public table"> <table id="my_category" server="{$site_url}/index.php?app=my_category&act=ajax_col"> <!-- {if $gcategories} --> <tr class="line_bold" > <th class="width1"><input id="all" type="checkbox" class="checkall" /></th> <th class="align1" colspan="5"> <label for="all"> <span class="all">{$lang.checkall}</span> </label> <a href="#" class="delete" ectype="batchbutton" uri="index.php?app=my_category&act=drop" name="id" presubmit="confirm('{$lang.drop_confirm}')">{$lang.drop}</a> <a href="index.php?app=my_category&step=newgcount" class="edit" ectype="batchbutton" uri="" name="id" >{$lang.newgcount}</a> </th> </tr> <tr class="gray" ectype="table_header"> <th></th> <th class="align1" coltype="editable" column="cate_name" checker="check_required" inputwidth="50%">{$lang.cate_name}</th> <th class="width15" coltype="editable" column="goodscount" checker="check_max" inputwidth="30px">{$lang.goodscount}</th> <th class="width15" coltype="editable" column="sort_order" checker="check_max" inputwidth="30px">{$lang.sort_order}</th> <th class="width15" coltype="switchable" column="if_show" checker="" offclass="wrong_ico">{$lang.if_show}</th> <th class="width3">{$lang.handle}</th> </tr> <!-- {/if} --> <!-- {if $gcategories} --> <tbody id="treet1"> <!-- {/if} --> <!-- {foreach from=$gcategories item=gcategory name=v} --> <tr class="line<!--{if $smarty.foreach.v.last}--> last_line<!--{/if}-->" ectype="table_item" idvalue="{$gcategory.cate_id}"> <td class="align2"><input type="checkbox" class="checkitem" value="{$gcategory.cate_id}" /></td> <td class="width7">  <span ectype="editobj">{$gcategory.cate_name|escape}</span>[id:{$gcategory.cate_id}]</td> <td class="align2">{$gcategory.goodscount}</td> <td class="align2"><span ectype="editobj">{$gcategory.sort_order}</span></td> <td> <p class="padding2"><span <!--{if $gcategory.if_show}-->class="right_ico" status="on"<!--{else}-->class="wrong_ico" status="off"<!--{/if}-->ectype="editobj"></span></p> </td> <td class="padding5"> <!-- {if $gcategory.layer lt 2} --> <a href="#" ectype="dialog" dialog_width="480" dialog_title="{$lang.add_child}" dialog_id="my_category_add" uri="index.php?app=my_category&act=add&pid={$gcategory.cate_id}" class="add1_ico">{$lang.add_child}</a> <!-- {/if} --> <a href="#" ectype="dialog" dialog_width="480" dialog_title="{$lang.edit}" dialog_id="my_category_edit" uri="index.php?app=my_category&act=edit&id={$gcategory.cate_id}" class="edit1">{$lang.edit}</a><a href="javascript:drop_confirm('{$lang.drop_confirm}', 'index.php?app=my_category&act=drop&id={$gcategory.cate_id}');" class="delete">{$lang.drop}</a> </td> </tr> <!-- {foreachelse} --> <tr> <td colspan="6" class="member_no_records padding6">{$lang.no_records}</td> </tr> <!--{/foreach}--> <!-- {if $gcategories} --> </tbody> <!-- {/if} --> <!-- {if $gcategories} --> <tr class="line_bold line_bold_bottom"> <td colspan="6"> </td> </tr> <tr> <th><input id="all2" type="checkbox" class="checkall" /></td> <th colspan="5"><p class="position1"><label for="all2"><span class="all">{$lang.checkall}</span></label> <a href="###" ectype="batchbutton" class="delete" uri="index.php?app=my_category&act=drop" name="id" presubmit="confirm('{$lang.drop_confirm}')">{$lang.drop}</a></p></td> </tr> <!-- {/if} --> </table> </div> <div class="wrap_bottom"></div> </div> 4.修改 my_category.app.php 增加重新计算商品数量 在index() 函数头增加 function index() { /*---TianYan 重新计算分类商品数-----*/ $db =&db(); if($_GET["step"]=="newgcount") { $rowlist = $db->getall("select * from ecm_gcategory where store_id='".$this->visitor->get('manage_store')."' "); foreach($rowlist as $row) { $cate_mod =& bm('gcategory', array('_store_id' => $this->visitor->get('manage_store'))); $cate_ids = $cate_mod->get_descendant(intval($_GET['sgcate_id'])); $gcounts = $db->getone("SELECT count( DISTINCT goods_id) FROM ecm_category_goodsWHERE cate_id =" . $row["cate_id"]); $db->query("update ecm_gcategory set goodscount='{$gcounts}' where cate_id='".$row["cate_id"]."' "); } } ![]()  | 
回答:
真牛啊!!!![]()  | 
| 果然是个高手,路过了,修改的地方没说明清楚 | 
| 真不错,,,强烈支持 | 
  ,,,强烈支持,,,强烈支持,,,强烈支持 | 
| 顶! 高手!! 感谢你无私的奉献!!  | 
| 复杂的问题要努力做到简单化! | 
强烈支持!![]()  | 
![]()  | 
| 按照一步步做下来后 出现 Fatal error: Call to a member function get() on a non-object in x:\....\htdocs\mall\app\frontend.base.php on line 39 请教下~会是什么原因呢?  | 
| 我是菜鸟,请lz说的清楚点好吗?看不懂啊 | 
| 还没有看懂的。 | 
原帖由 tianyan 于 2009-8-29 14:02 发表 请问这个商品数据表ecm_gcategory在那里呢?我是个菜鸟,请高手指点,谢谢了  | 
| 怎么把这个商品统计放到店铺页面去呢,。 我想会有一点用处的。  | 
| 请问TianYan版主, 如何在店铺首页 显示店铺每个商品分类的商品数量。 按照一楼的方式设定完成后 我到themes/store/default/left.html 试着把 {$gcategory.goodscount} 加在{$gcategory.value|escape} 后面 可是显示不出数量....  | 
 
        
					
						
					
					
						
                          
					
				 
      
      最近更新
常用插件
- ecshop根据订单批量发红包
                                  
ecshop根据订单批量发红包 ,大家肯定对ecshop红包不陌生,但是对ecshop订...
 - ecshop 手机注册验证插件
                                  
ecshop 手机注册验证插件 ,需要通过手机获短信,然后注册验证 价格:...
 - ecshop中nginx实现url的重写
                                  
上几章为了让ecshop很好的在nginx上运行。我们搭配了ecshop的nginx下的工作...
 - ecshop商品分类名称增加样
                                  
ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样...
 - ecshop使用手机验证码登陆
                                  
ecshop使用手机验证码登陆,这个功能很新颖,有些特殊的ecshop站点,他到...
 
ecshop热门问答
ecshop热门资料
          
               
            ecshop严重 
                
            ecshop退出 
                
            ecshop整站多城市切换 
                
            ecshop销售站 
                
            ecshop商品折扣 
                
            ecshop本网价格 
                
            ecshop163 
                
            ecshop增加必填信息 
                
            ecshop竞价广告 
                
            ecshop选择 
                
            javamongodb 
                
            ecshopWampServer 
                
            ecshopwatermark 
                
            ecshop使用 
                
            ecshop个性安全套 
                
            ecshop盛付通 
                
            ecshopUCHOME 
                
            ecshop快捷登录 
                
            ecshop0字节 
                
            ecshop备齐 
                
            ecshop的 
                
            ecshop头痛 
                
            ecshopsina 
                
            ecshop缩略图问题 
                
            ecshop剪贴 
                
            zencart分类树 
                
            ecshop广告图片 
                
            ecshop提问 
                
            ecshop关联商品 
                
            ecshop数据结构 
             
        
      







