コード例 #1
0
ファイル: SearchProducts.php プロジェクト: phaniapsr/yiicomm
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Products::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['ProductId' => $this->ProductId, 'ProductCategoryId' => $this->ProductCategoryId, 'SupplierId' => $this->SupplierId, 'BrandId' => $this->BrandId, 'ProductTypeId' => $this->ProductTypeId, 'DiscountPercent' => $this->DiscountPercent, 'CommissionPercent' => $this->CommissionPercent, 'TaxPercent' => $this->TaxPercent, 'Price' => $this->Price, 'PriceMarket' => $this->PriceMarket, 'PriceSupplier' => $this->PriceSupplier, 'MaximumPurchaseCount' => $this->MaximumPurchaseCount, 'IsActive' => $this->IsActive, 'IsFeatured' => $this->IsFeatured, 'IsOnVote' => $this->IsOnVote, 'VoteCount' => $this->VoteCount, 'created_by' => $this->created_by, 'LastUpdatedBy' => $this->LastUpdatedBy, 'PublishedOn' => $this->PublishedOn, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at, 'deleted_at' => $this->deleted_at]);
     $query->andFilterWhere(['like', 'Gender', $this->Gender])->andFilterWhere(['like', 'Name', $this->Name])->andFilterWhere(['like', 'SupplierDescription', $this->SupplierDescription])->andFilterWhere(['like', 'Description', $this->Description])->andFilterWhere(['like', 'ShortDescription', $this->ShortDescription])->andFilterWhere(['like', 'HtmlDescription', $this->HtmlDescription])->andFilterWhere(['like', 'UrlName', $this->UrlName])->andFilterWhere(['like', 'Comment', $this->Comment]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: phaniapsr/yiicomm
 public function actionIndex()
 {
     $subcats = array();
     $categories = Productcategories::find()->where('ParentProductCategoryId= 0')->asArray()->all();
     foreach ($categories as $row) {
         $sub = Productcategories::find()->where('ParentProductCategoryId = ' . $row['ProductCategoryId'])->asArray()->all();
         array_push($subcats, $sub);
     }
     $featuredProducts = Products::find()->with('productmedias')->where('IsFeatured = 1')->asArray()->all();
     return $this->render('index', ['categories' => $categories, 'subcats' => $subcats, 'featuredProducts' => $featuredProducts]);
 }
コード例 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Products::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'cat_id' => $this->cat_id, 'position' => $this->position, 'publish' => $this->publish, 'create_date' => $this->create_date, 'update_date' => $this->update_date]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'alias', $this->alias]);
     return $dataProvider;
 }
コード例 #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Products::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'article' => $this->article, 'mass' => $this->mass, 'price' => $this->price, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'unit', $this->unit])->andFilterWhere(['like', 'image', $this->image]);
     return $dataProvider;
 }
コード例 #5
0
ファイル: ShopController.php プロジェクト: phaniapsr/yiicomm
 public function actionIndex($id = null)
 {
     $sidebarcategories = Productcategories::find()->where('ParentProductCategoryId = 0')->asArray()->all();
     if ($id === 0 || $id == null) {
         $query = Products::find()->with('productmedias');
         $countQuery = clone $query;
         $pages = new Pagination(['totalCount' => $countQuery->count(), 'defaultPageSize' => 3]);
         $products = $query->offset($pages->offset)->limit($pages->limit)->asArray()->all();
         $countProducts = Products::find()->count();
         $pagetitle = ['Name' => 'All products'];
     } else {
         $query = Products::find()->with('productmedias')->where('ProductCategoryId = ' . $id);
         $countQuery = clone $query;
         $pages = new Pagination(['totalCount' => $countQuery->count(), 'defaultPageSize' => 3]);
         $products = $query->offset($pages->offset)->limit($pages->limit)->asArray()->all();
         $countProducts = Products::find()->where('ProductCategoryId = ' . $id)->count();
         $pagetitle = Productcategories::find()->where('ProductCategoryId = ' . $id)->asArray()->one();
     }
     return $this->render('index', ['sidebarcategories' => $sidebarcategories, 'products' => $products, 'pages' => $pages, 'countProducts' => $countProducts, 'pagetitle' => $pagetitle]);
 }
コード例 #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProducts()
 {
     return $this->hasMany(Products::className(), ['ProductCategoryId' => 'ProductCategoryId']);
 }
コード例 #7
0
ファイル: _form.php プロジェクト: phaniapsr/yiicomm
<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\bootstrap\ActiveForm;
use common\models\Products;
use common\models\Stockunits;
use common\models\Campaigns;
/* @var $this yii\web\View */
/* @var $model common\models\Campaignproducts */
/* @var $form yii\widgets\ActiveForm */
$dataCampaigns = ArrayHelper::map(Campaigns::find()->asArray()->all(), 'CampaignId', 'Name');
$dataProducts = ArrayHelper::map(Products::find()->asArray()->all(), 'ProductId', 'Name');
$dataStockUnits = ArrayHelper::map(Stockunits::find()->asArray()->all(), 'StockUnitId', 'Name');
?>

<div class="campaignproducts-form">

    <?php 
$form = ActiveForm::begin(['layout' => 'horizontal']);
?>

    <?php 
echo $form->field($model, 'CampaignId', ['horizontalCssClasses' => ['wrapper' => 'col-sm-3']])->dropDownList($dataCampaigns, ['prompt' => 'Choose a Campaign']);
?>

    <?php 
echo $form->field($model, 'ProductId', ['horizontalCssClasses' => ['wrapper' => 'col-sm-4']])->dropDownList($dataProducts, ['prompt' => 'Choose a Product']);
?>

    <?php 
コード例 #8
0
ファイル: Productoptions.php プロジェクト: phaniapsr/yiicomm
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProduct()
 {
     return $this->hasOne(Products::className(), ['ProductId' => 'ProductId']);
 }
コード例 #9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProducts()
 {
     return $this->hasMany(Products::className(), ['cat_id' => 'id']);
 }
コード例 #10
0
 /**
  * Finds the Products model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Products the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Products::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #11
0
 /**
  * Products.
  *
  * @return mixed
  */
 public function actionProducts()
 {
     try {
         $product_id = Yii::$app->request->queryParams["id"];
         $product = Products::getProductById($product_id);
         $model = Categories::getCategories($product['cat_id']);
         $modelParent = Categories::getCategoriesParent($product['cat_id']);
     } catch (InvalidParamException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
     // breadcrumbs
     $parent_breadcrumbs = array();
     $i = 0;
     $parent_breadcrumbs[$i] = Categories::getCategoriesParent($modelParent['parent_id']);
     $parent_cat = NULL;
     while ($parent_cat = Categories::getCategoriesParent($parent_breadcrumbs[$i]['parent_id'])) {
         $i++;
         $parent_breadcrumbs[$i] = $parent_cat;
     }
     return $this->render('products', ['model' => $model, 'modelParent' => $modelParent, 'parent_breadcrumbs' => $parent_breadcrumbs, 'product' => $product]);
 }
コード例 #12
0
 /**
  * Get Products
  *
  * @param $id
  * @return ActiveDataProvider
  */
 private function _getProducts($id)
 {
     if ($id > 0) {
         // Search all subcategories
         $columnCats = array_column($this->_categories, 'parent_id', 'id');
         $searchCats = $result = [$id];
         while (true) {
             $foundCats = [];
             foreach ($searchCats as $cat) {
                 $cats = array_keys($columnCats, $cat);
                 $foundCats = array_merge($foundCats, $cats);
             }
             if (empty($foundCats)) {
                 break;
             }
             $result = array_merge($result, $foundCats);
             $searchCats = $foundCats;
         }
         return new ActiveDataProvider(['query' => Products::find()->where(['category_id' => $result, 'status' => 1])]);
     } else {
         return new ActiveDataProvider(['query' => Products::find()->where(['status' => 1])]);
     }
 }