コード例 #1
0
ファイル: ProductController.php プロジェクト: sergey-exu/diru
 public function actionView($type, $alias)
 {
     $model = Product::find()->where(['product_type' => $type, 'alias' => $alias])->one();
     if (!$model) {
         throw new NotFoundHttpException(\Yii::t('backend', 'Page not found'));
     }
     return $this->render('view', ['model' => $model]);
 }
コード例 #2
0
ファイル: ProductSearch.php プロジェクト: phanthehung/onepx
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Product::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, 'manufacture_id' => $this->manufacture_id, 'state' => $this->state, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'guid', $this->guid])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'short_description', $this->short_description])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'extension', $this->extension]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: ProductSearch.php プロジェクト: sergey-exu/diru
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Product::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'product_img', $this->product_img])->andFilterWhere(['like', 'product_type', $this->product_type])->andFilterWhere(['like', 'product_name', $this->product_name])->andFilterWhere(['like', 'product_summary', $this->product_summary])->andFilterWhere(['like', 'product_description', $this->product_description])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'alias', $this->alias]);
     return $dataProvider;
 }
コード例 #4
0
ファイル: Campaign.php プロジェクト: timelessmemory/uhkklp
 /**
  * search the product id from the campaign
  * @param $accountId,MongoId
  * @param $pageSize,int,the number record for one page
  * @param $page,int, which page to show
  */
 public static function searchProductInfo($accountId, $pageSize, $page)
 {
     $where = ['accountId' => $accountId, 'isDeleted' => self::NOT_DELETED];
     $campaigns = Campaign::find()->select(['promotion.data'])->where($where)->all();
     $showData = [];
     //get productId
     if (!empty($campaigns)) {
         $productIds = [];
         foreach ($campaigns as $campaign) {
             if (!empty($campaign['promotion']['data'])) {
                 $ids = $campaign['promotion']['data'];
                 foreach ($ids as $id) {
                     $productIds[] = $id;
                 }
             }
         }
         //get product info from product with productId
         if (!empty($productIds)) {
             $productIds = array_values(array_unique($productIds));
             $len = count($productIds);
             $offset = 0;
             $where = ['_id' => ['$in' => $productIds]];
             $query = Product::find()->select(['_id', 'name'])->where($where);
             if ($len > $pageSize && $pageSize > 0) {
                 $offset = ($page - 1) * $pageSize;
                 $showData = $query->offset($offset)->limit($pageSize);
             }
             $showData = $query->all();
         }
     }
     $data = ['data' => $showData, 'num' => empty($len) ? 0 : $len];
     return $data;
 }
コード例 #5
0
ファイル: index.php プロジェクト: sergey-exu/diru
<?php

use yii\helpers\Html;
//use yii\widgets\ListView;
use yii\grid\GridView;
use backend\modules\product\models\Product;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = $type;
$this->params['breadcrumbs'][] = ['label' => 'Продукция', 'url' => '/#products'];
$this->params['breadcrumbs'][] = $this->title;
$this->params['right_menu_page'] = [['label' => 'Производство', 'url' => ['/page/view', 'alias' => 'proizvodstvo']], ['label' => 'О нас', 'url' => ['/page/view', 'alias' => 'about']]];
foreach (Product::find()->groupBy('product_type')->all() as $data) {
    $this->params['right_menu'][] = ['label' => Product::getProductTypeName2($data->product_type), 'url' => ['/product/index', 'type' => $data->product_type]];
}
$this->registerJsFile('/js/filtrproducts.js');
?>

<!--Фильтр товаров-->
<div class="container">
    <div class="row">
        <div class="col-md-8">
            <form>
                <div class="form-process"></div>
                <div class="col-md-8 form-group">
                    <input type="search" class="light-table-filter" data-table="table" placeholder="Поиск">
                </div>
            </form>
        </div>
    </div>
</div>
コード例 #6
0
ファイル: Product.php プロジェクト: timelessmemory/uhkklp
 /**
  *check the property is required
  */
 public static function checkParam($params, $accountId)
 {
     //check the sku
     if (isset($params['sku'])) {
         $result = Product::find()->where(['sku' => $params['sku'], 'isDeleted' => false])->one();
         if ($result) {
             throw new InvalidParameterException(['number' => Yii::t("product", "number_isUsed")]);
         }
     }
     if (empty($params['category'])) {
         return true;
     }
     $where = ['isDeleted' => false, 'accountId' => $accountId, '_id' => new \MongoId($params['category']['id'])];
     $categoryInfos = ProductCategory::find()->where($where)->all();
     if (empty($categoryInfos)) {
         throw new ServerErrorHttpException('Fail to find the properties');
     }
     $requiredData = [];
     foreach ($categoryInfos as $categoryInfo) {
         foreach ($categoryInfo['properties'] as $cproperties) {
             if ($cproperties['isRequired']) {
                 $requiredData[] = $cproperties['id'];
             }
         }
     }
     if (count($requiredData) > 0 && empty($params['category']['properties'])) {
         throw new InvalidParameterException([$requiredData[0] => Yii::t('product', 'property_required')]);
     } else {
         if (count($requiredData) > 0 && !empty($params['category']['properties'])) {
             foreach ($params['category']['properties'] as $properties) {
                 $userData[] = $properties['id'];
             }
         }
     }
     foreach ($requiredData as $key => $value) {
         if (!in_array($value, $userData)) {
             throw new InvalidParameterException([$value => \Yii::t('product', 'property_required')]);
         }
     }
 }
コード例 #7
0
 public static function _generateCodePrefix($productId)
 {
     $year = date('y');
     $year = $year - 10;
     //start from 2015
     $yearPrefix = self::_getPrefix(1, $year);
     $product = Product::findByPk($productId);
     $productIndex = Product::find()->where(['createdAt' => ['$lte' => $product->createdAt], 'accountId' => $product->accountId])->orderBy(['createdAt' => SORT_ASC])->count();
     $productPrefix = self::_getPrefix(2, $productIndex);
     $batchPrefix = self::_getPrefix(1, $product->batchCode);
     return $yearPrefix . $productPrefix . $batchPrefix;
 }