/**
  * Finds the Manufacturer model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Manufacturer the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Manufacturer::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#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]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Manufacturer::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 actionBrand($alias)
 {
     /** @var $category Category */
     $category = Manufacturer::find()->where(['alias' => $alias])->one();
     if (!$category) {
         throw new HttpException(404, 'Категория товара не найдена');
     }
     $q = \Yii::$app->request->get('q');
     if (!empty($q)) {
         $products = Product::find()->where(['manufacturerId' => $category->id])->visible()->andWhere(['like', 'title', $q])->all();
     } else {
         $products = $category->products;
     }
     $route = $this->route;
     $title = 'Товары - Производители - ' . $category->title;
     return $this->render('view', ['category' => $category, 'products' => $products, 'q' => $q, 'route' => $route, 'title' => $title]);
 }
示例#5
0
                        <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 
echo Url::to(['/store/admin/product']);
?>
">Товары <i
                                class="badge"><?php 
echo \app\modules\store\models\Product::getCount();
?>
</i></a>
                    </li>
                   <li>
                       <a href="<?//= Url::to(['/store/admin/order']) ?>">Заказы <i class="badge"><?//= \app\modules\store\models\Order::getCount() ?></i></a>
示例#6
0
 public function getManufacturer()
 {
     return $this->hasOne(Manufacturer::className(), ['id' => 'manufacturerId']);
 }