예제 #1
0
 public static function getSalesOrderBy($categoryId = '')
 {
     $where = '';
     if ($categoryId) {
         $items = Tree::find()->where(['tree_id' => $categoryId])->all();
         $itemIds = ArrayHelper::getColumn($items, 'item_id');
         $where = ' where item_id in (' . implode(',', $itemIds) . ') ';
     }
     $sql = 'SELECT name, count(item_id) as count FROM `order_item` ' . $where . ' group by item_id order by count desc';
     return Yii::$app->db->createCommand($sql)->queryAll();
 }
예제 #2
0
파일: Tree.php 프로젝트: shuangjie/galaxy
 public static function getTreesById($id)
 {
     /** @var \star\system\models\Tree|\creocoder\nestedsets\NestedSetsBehavior $root */
     $root = static::find()->where(['id' => $id])->one();
     if ($root) {
         $categories = Tree::find()->where('lft >= ' . $root->lft . ' and rgt <= ' . $root->rgt . ' and root = ' . $root->root . ' order by id desc')->indexBy('id')->all();
         return array_map(function ($cate) use($root) {
             return $cate->name;
         }, $categories);
     } else {
         return false;
     }
 }
예제 #3
0
파일: view.php 프로젝트: shuangjie/galaxy
<!--</figure>-->
<!--</div>-->
<hr class="divider_type_3 m_bottom_15">
<a href="category_grid.html" role="button" class="d_inline_b bg_light_color_2 color_dark tr_all_hover button_type_4 r_corners"><i class="fa fa-reply m_left_5 m_right_10 f_size_large"></i>Back to: Woman</a>
</section>
<!--right column-->
<aside class="col-lg-3 col-md-3 col-sm-3">
    <figure class="widget shadow r_corners wrapper m_bottom_30">
        <figcaption>
            <h3 class="color_light">Categories</h3>
        </figcaption>
        <div class="widget_content">
            <!--Categories list-->
            <ul class="categories_list">
                <?php 
$tree = Tree::find()->where(['name' => '商品分类'])->one();
$childrenTags = $tree->children('1')->all();
foreach ($childrenTags as $childrenTag) {
    $secondChildren = $childrenTag->children('1')->all();
    ?>
                    <li>
                        <a href="#" class="f_size_large color_dark d_block relative">
                            <b><?php 
    echo $childrenTag->name;
    ?>
</b>
                            <span class="bg_light_color_1 r_corners f_right color_dark talign_c"></span>
                        </a>
                    <?php 
    if ($secondChildren) {
        ?>
예제 #4
0
파일: main.php 프로젝트: shuangjie/galaxy
            <span class="centered_db r_corners"></span>
        </button>
        <!--main menu-->
        <nav role="navigation" class="f_left f_xs_none d_xs_none">
            <ul class="horizontal_list main_menu clearfix">
                <li class="<?php 
echo Yii::$app->request->get('catalog') || Yii::$app->request->get('tab') ? '' : 'current';
?>
 relative f_xs_none m_xs_bottom_5">
                    <a href="<?php 
echo Url::to(['/']);
?>
" class="tr_delay_hover color_light tt_uppercase"><b>首页</b></a>
                </li>
                <?php 
$root = \star\system\models\Tree::find()->where(['name' => '商品分类'])->one();
if ($root) {
    $categories = $root->children(1)->indexBy('id')->limit(5)->all();
    if ($categories) {
        foreach ($categories as $category) {
            ?>
                <li class="<?php 
            echo Yii::$app->request->get('catalog') == $category->id ? 'current' : '';
            ?>
 relative f_xs_none m_xs_bottom_5">
                    <a href="<?php 
            echo Url::to(['/catalog/home/item/list', 'catalog' => $category->id]);
            ?>
" class="tr_delay_hover color_light tt_uppercase"><b><?php 
            echo $category->name;
            ?>