ecmall挂件 商品分类 + 分类下品牌 gcategory_brand_list

转载自:ecmall挂件 商品分类 + 分类下品牌 gcategory_brand_list

在gcategory_list挂件基础上修改的一个挂件,增加了展示分类下品牌,品牌显示个数可配置

widget.info.php

1
2
3
4
5
6
7
8
9
10
11
12
<?php
return array (
  'name'      =>  'gcategory_brand_list' ,
  'display_name'  =>  '商品分类 + 分类下品牌' ,
  'author'    =>  'Heui' ,
  'website'   =>  'http://blog.runphp.net' ,
  'version'   =>  '1.0' ,
  'desc'      =>  '展示第一第二级商品分类和一级分类下品牌,适合放在比较宽的区域' ,
  'configurable'  => true,
);
 
?>

main.widget.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
 
/**
  * 商品分类挂件
  *
  * @return  array   $category_brand_list
  */
class Gcategory_brand_listWidget  extends BaseWidget
{
     var $_name 'gcategory_brand_list' ;
     var $_ttl  = 86400;
 
     function _get_data()
     {
         $this ->options[ 'amount_cate' ] =  intval ( $this ->options[ 'amount_cate' ]);
         $this ->options[ 'amount_brand' ] =  intval ( $this ->options[ 'amount_brand' ]);
 
         $cache_server =& cache_server();
         $key $this ->_get_cache_id();
         $data $cache_server ->get( $key );
         if ( $data === false)
         {
             $gcategory_mod =& bm( 'gcategory' array ( '_store_id' => 0));
             $gcategories array ();
             if ( empty ( $this ->options[ 'amount_cate' ]))
             {
                 $gcategories $gcategory_mod ->get_list(-1, true);
             }
             else
             {
                 $gcategory $gcategory_mod ->get_list(0, true);
                 $gcategories $gcategory ;
                 foreach ( $gcategory as $val )
                 {
                     $result $gcategory_mod ->get_list( $val [ 'cate_id' ], true);
                     $result array_slice ( $result , 0,  $this ->options[ 'amount_cate' ]);
                     $gcategories array_merge ( $gcategories $result );
                 }
             }
             import( 'tree.lib' );
             $tree new Tree();
             $tree ->setTree( $gcategories 'cate_id' 'parent_id' 'cate_name' );
 
             $data $tree ->getArrayList(0);
             $cache_server ->set( $key $data $this ->_ttl);
         }
/新增加的品牌分类//
//echo $this->options['amount_brand'];exit;
 
         $good_mod =& m( 'goods' );
 
         foreach ( $data as $key => & $val ){
             $result $good_mod ->get_list(
                         array ( 'conditions' =>  "cate_id_1 = " . $val [ 'id' ],
             ));
 
             foreach ( $result as $key =>  $value )  {
                 if (! empty ( $value [ 'brand' ])){
                     $val [ 'brand' ][ $key ] =  $value [ 'brand' ];
                 }
             }
 
             if (! is_null ( $val [ 'brand' ])){
                 $val [ 'brand' ] =  array_unique ( $val [ 'brand' ]);
                 if (! empty ( $this ->options[ 'amount_brand' ])) {
                     $val [ 'brand' ] =  array_slice ( $val [ 'brand' ], 0,  $this ->options[ 'amount_brand' ]);;
                 }
             } else {
                 $val [ 'brand' ] = null;
             }
         }
/
         return $data ;
     }
 
     function parse_config( $input )
     {
         $result array ();
         $result [ 'amount_cate' ] =  $input [ 'amount_cate' ];
         $result [ 'amount_brand' ] =  $input [ 'amount_brand' ];
         return $result ;
     }
}
 
?>

ecmall挂件下载:
gcategory_brand_list

转载于:https://www.cnblogs.com/heui/archive/2011/04/02/2004125.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值