/**
  * Finds the Category model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Category the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Category::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 2
0
 public function run()
 {
     $alias = \Yii::$app->request->get('alias');
     if (\Yii::$app->controller->route != 'store/category/brand') {
         $type = 'category';
         $items = \app\modules\store\models\Category::getNavigationData();
     } else {
         $type = 'brand';
         $items = \app\modules\store\models\Manufacturer::getNavigationData();
     }
     return $this->render('categoryNavView', ['items' => $items, 'type' => $type, 'alias' => $alias]);
 }
Ejemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Category::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['position' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'visible' => $this->visible, 'position' => $this->position]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias]);
     return $dataProvider;
 }
 public function actionView($alias)
 {
     /** @var $category Category */
     $category = Category::find()->where(['alias' => $alias])->one();
     if (!$category) {
         throw new HttpException(404, 'Категория товара не найдена');
     }
     $q = \Yii::$app->request->get('q');
     if (!empty($q)) {
         $products = Product::find()->where(['categoryId' => $category->id])->visible()->andWhere(['like', 'title', $q])->all();
     } else {
         $products = $category->products;
     }
     $route = $this->route;
     $title = 'Товары - Категории - ' . $category->title;
     $categoryList = Category::find()->with(['products'])->orderBy(['position' => SORT_ASC])->all();
     return $this->render('view', ['category' => $category, 'products' => $products, 'q' => $q, 'route' => $route, 'title' => $title, 'categoryList' => $categoryList]);
 }
Ejemplo n.º 5
0
                    <!--                        <a href="--><? //=Url::to(['/cms/admin/config'])?><!--">Настройки</a>-->
                    <!--                    </li>-->
                </ul>
                <!-- /.nav-second-level -->
            </li>

            <!-- li>
                <a href="#"><i class="fa fa-android fa-fw"></i> Каталог<span class="fa arrow"></span></a>
                <ul class="nav nav-second-level">
                    <li>
                        <a href="<?php 
echo Url::to(['/store/admin/category']);
?>
">Категории <i
                                class="badge"><?php 
echo \app\modules\store\models\Category::getCount();
?>
</i></a>
                    </li>
                    <li>
                        <a href="<?php 
echo Url::to(['/store/admin/manufacturer']);
?>
">Производители <i
                                class="badge"><?php 
echo \app\modules\store\models\Manufacturer::getCount();
?>
</i></a>
                    </li>
                    <li>
                        <a href="<?php 
Ejemplo n.º 6
0
 public function getCategory()
 {
     return $this->hasOne(Category::className(), ['id' => 'categoryId']);
 }
Ejemplo n.º 7
0
?>

<div class="product-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'visible')->checkbox();
?>

    <div class="row">
        <div class="col-md-12">
            <?php 
echo $form->field($model, 'categoryId')->dropDownList(\app\modules\store\models\Category::dropDown(), ['prompt' => 'Выбор']);
?>
        </div>
<!--        <div class="col-md-6">-->
<!--            --><?//= $form->field($model, 'manufacturerId')->dropDownList(\app\modules\store\models\Manufacturer::dropDown(),['prompt'=>'Выбор']) ?>
<!--        </div>-->
    </div>

    <div class="row">
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 128]);
?>
        </div>
        <div class="col-md-6">
            <?php 
Ejemplo n.º 8
0
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $model \app\modules\store\models\Category */
/* @var $searchModel app\modules\store\models\CategorySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Категории');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-index">


    <p>
        <?php 
echo Html::a(Yii::t('app', 'Добавить'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <pre>Ссылка на модуль: <?php 
echo htmlspecialchars('<?=\\yii\\helpers\\Url::to(["/store/category"])?>');
?>
</pre>


    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['header' => '', 'format' => 'html', 'value' => function ($model) {
    return Html::img($model->image->resize('32x29'));
}], 'title', 'alias', ['attribute' => 'visible', 'value' => 'visibleDisplay', 'filter' => \app\modules\store\models\Category::visibleList()], 'position', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Ejemplo n.º 9
0
?>
        <?php 
NavBar::begin(['brandLabel' => Yii::$app->name, 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => 'Отзывы', 'url' => ['/cms/reviews/index']], ['label' => 'Статьи', 'url' => ['/cms/article/list', 'type' => 'article']], ['label' => 'Новости', 'url' => ['/cms/article/list', 'type' => 'news']], ['label' => 'Акции', 'url' => ['/cms/article/list', 'type' => 'stock']]]]);
NavBar::end();
?>
<br/><br/><br/>
        <div class="container">
            <div class="row">
                <div class="col-md-4">
                    <div class="panel panel-success">
                        <div class="panel-heading">Каталог</div>
                        <div class="panel-body">
                            <ul class="nav nav-pills nav-stacked">
                                <?php 
foreach (\app\modules\store\models\Category::getNavigationData() as $item) {
    ?>
                                <li>
                                    <?php 
    echo Html::a(Html::img($item->image->resize('33x30')) . ' ' . $item->title, $item->path);
    ?>
                                </li>
                                <?php 
}
?>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="col-md-8">
                    <?php