catalogSubmenuWidget.php
700 Bytes
<?php
namespace common\modules\product\widgets;
use common\modules\product\models\Category;
use yii\base\Widget;
class catalogSubmenuWidget extends Widget {
    public $root_id;
    public $rootClass = '';
    public function init()
    {
        parent::init(); // TODO: Change the autogenerated stub
    }
    public function run() {
        $rootCategory = Category::findOne($this->root_id);
        return $this->render('submenu', [
            'rootCategory' => $rootCategory,
            'rootClass' => $this->rootClass,
            'populary' => $rootCategory->getAllChildren(2, ['populary' => true])->all(),
            'items' => $rootCategory->getAllChildrenTree(2)
        ]);
    }
}