コード例 #1
0
 public function searchEmptyBrand($params)
 {
     $query = RivegaucheProduct::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->where('brand is null or brand =""');
     $query->andFilterWhere(['like', 'article', $this->article])->andFilterWhere(['like', 'link', $this->link])->andFilterWhere(['like', 'group', $this->group])->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'sub_category', $this->sub_category])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'gold_price', $this->gold_price])->andFilterWhere(['like', 'blue_price', $this->blue_price])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'image_link', $this->image_link]);
     return $dataProvider;
 }
コード例 #2
0
 public function actionRpodr()
 {
     $entity = new RivegaucheProduct();
     $offset = 0;
     do {
         $products = $entity->getEntity($offset, 20);
         if (!empty($products)) {
             foreach ($products as $product) {
                 if (empty($product->rive_id)) {
                     $query = new Query();
                     $str = '';
                     $rows = $query->from('pproduct')->match(new Expression(':match', ['match' => '@(description) ' . \Yii::$app->sphinx->escapeMatchValue($product->title)]))->all();
                     foreach ($rows as $row) {
                         if (!empty($row['id'])) {
                             // проставляем идентификатор
                             $str = $row['id'];
                             break;
                         }
                     }
                     // обновляем таблицу podruzka_product
                     if (!empty($str)) {
                         $productEntity = PodruzkaProduct::findOne(['id' => $str]);
                         if ($productEntity instanceof PodruzkaProduct) {
                             $productEntity->rive_id = (string) $product->id;
                             $productEntity->save();
                         }
                     }
                 }
             }
             $z = 1;
             $offset += 20;
             unset($productEntity);
             unset($query);
         } else {
             $z = 0;
         }
     } while ($z > 0);
     return 0;
 }
コード例 #3
0
 /**
  * Finds the RivegaucheProduct model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return RivegaucheProduct the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = RivegaucheProduct::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getR()
 {
     return $this->hasOne(RivegaucheProduct::className(), ['id' => 'r_id']);
 }
コード例 #5
0
ファイル: header.php プロジェクト: Ellumilel/analitics
                            <span class="label label-danger"><?php 
    echo $count;
    ?>
</span>
                        <?php 
}
?>
                    </a>
                    <ul class="dropdown-menu">
                        <li class="header">Сообщения системы</li>
                        <li>
                            <!-- inner menu: contains the actual data -->
                            <div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto; height: 200px;"><ul class="menu" style="overflow: hidden; width: 100%; height: 200px;">
                                    <li>
                                        <?php 
if ($lCount = \app\models\RivegaucheProduct::getEmptyBrand()) {
    ?>
                                        <a href="<?php 
    echo \yii\helpers\Url::to(['/rivegauche-product/empty-brand']);
    ?>
">
                                                <i class="fa fa-warning text-red"></i>
                                                Пустые бренды у РивГош (<?php 
    echo $lCount;
    ?>
)
                                        </a>
                                        <?php 
}
?>
                                    </li>
コード例 #6
0
 /**
  * @return string
  */
 public function actionArticleUpdate()
 {
     if ($pArticle = reset($_POST['PodruzkaProduct'])['article']) {
         if ($pp = PodruzkaProduct::find()->where(['article' => $pArticle])->one()) {
             if (!empty($_POST['l_id'])) {
                 if ($lp = LetualProduct::find()->where(['article' => $_POST['l_id']])->one()) {
                     $pp->l_id = $lp->id;
                 }
             } else {
                 $pp->l_id = null;
             }
             if (!empty($_POST['r_id'])) {
                 if ($rp = RivegaucheProduct::find()->where(['article' => $_POST['r_id']])->one()) {
                     $pp->r_id = $rp->id;
                 }
             } else {
                 $pp->r_id = null;
             }
             if (!empty($_POST['i_id'])) {
                 if ($ip = IledebeauteProduct::find()->where(['article' => $_POST['i_id']])->one()) {
                     $pp->i_id = $ip->id;
                 }
             } else {
                 $pp->i_id = null;
             }
             if (!empty($_POST['e_id'])) {
                 if ($ep = ElizeProduct::find()->where(['article' => $_POST['e_id']])->one()) {
                     $pp->e_id = $ep->id;
                 }
             } else {
                 $pp->e_id = null;
             }
             $pp->save();
             return json_encode(['result' => true]);
         }
     }
     return json_encode(['result' => false]);
 }
コード例 #7
0
 /**
  * @param Response $result
  */
 private function saveResult(Response $result)
 {
     $product = RivegaucheProduct::findOne(['article' => $result->getArticle()]);
     if (!$product) {
         $product = new RivegaucheProduct();
     }
     $product->attributes = $result->toArray();
     try {
         $rPrice = new RivegauchePrice();
         $rPrice->article = $result->getArticle();
         if ($result->getGoldPrice()) {
             $rPrice->gold_price = $result->getGoldPrice();
         }
         if ($result->getBluePrice()) {
             $rPrice->blue_price = $result->getBluePrice();
         }
         if ($result->getPrice()) {
             $rPrice->price = $result->getPrice();
         }
         $product->deleted_at = '0000-00-00 00:00:00';
         if ($product->save()) {
             if (!empty($rPrice->price) || !empty($rPrice->blue_price) || !empty($rPrice->gold_price)) {
                 $rPrice->save();
             }
         } else {
             \Yii::error(sprintf('Ошибка сохранения артикула R: %s data: %s', $result->getArticle(), json_encode($result->toArray())), 'cron');
         }
     } catch (\Exception $e) {
         \Yii::error(sprintf('Exception %s сохранения артикула R %s data: %s', $e->getMessage(), $result->getArticle(), json_encode($result->toArray())), 'cron');
     }
 }
コード例 #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getArticle0()
 {
     return $this->hasOne(RivegaucheProduct::className(), ['article' => 'article']);
 }
コード例 #9
0
 /**
  * @param $result
  * @param $link
  */
 private function saveResult($result, $link)
 {
     \Yii::info(sprintf('Сохраняем тело: %s ', json_encode($result)), 'cron');
     if (empty($result) || empty($result['link']) || empty($result['title']) || empty($result['category'])) {
         return;
     } else {
         \Yii::error('Ошибка сохранения артикула R: ' . json_encode($result), 'cron');
     }
     preg_match('/[0-9]+$/i', $result['link'], $data);
     $article = $data[0];
     unset($data);
     $product = RivegaucheProduct::findOne(['article' => $article]);
     if (!$product) {
         $product = new RivegaucheProduct();
     }
     $product->brand = $this->clearBrand($result);
     $product->title = $result['title'];
     $product->article = $article;
     $product->category = $link['category'];
     $product->group = $link['group'];
     $product->link = $result['link'];
     $product->sub_category = $link['sub_category'];
     $product->image_link = !empty($result['image_link']) ? $result['image_link'] : '';
     $product->description = !empty($result['description']) ? $result['description'] : '';
     $product->showcases_offer = $result['showcases_offer'];
     $product->showcases_new = $result['showcases_new'];
     $product->showcases_exclusive = $result['showcases_exclusive'];
     $product->showcases_compliment = $result['showcases_compliment'];
     $product->showcases_bestsellers = $result['showcases_bestsellers'];
     $product->showcases_expertiza = $result['showcases_expertiza'];
     $product->gold_price = $this->getPrice($result['price']['gold_price']);
     $product->blue_price = $this->getPrice($result['price']['blue_price']);
     $product->price = $this->getPrice($result['price']['price']);
     try {
         $rPrice = new RivegauchePrice();
         $rPrice->article = $article;
         $rPrice->gold_price = $this->getPrice($result['price']['gold_price']);
         $rPrice->blue_price = $this->getPrice($result['price']['blue_price']);
         $rPrice->price = $this->getPrice($result['price']['price']);
         if ($product->save()) {
             $rPrice->save();
         } else {
             \Yii::error('Ошибка сохранения артикула R: ' . json_encode($result), 'cron');
         }
     } catch (\Exception $e) {
         \Yii::error(sprintf('Exception %s сохранения артикула R: %s', $e->getMessage(), json_encode($result)), 'cron');
     }
 }
コード例 #10
0
ファイル: TextHelper.php プロジェクト: Ellumilel/analitics
 /**
  * Возвращает строку с инпутами для таблицы с формой сопоставления
  *
  * @param $model
  *
  * @return string
  */
 public static function getArticleMatchingForm($model)
 {
     $result = Html::activeLabel($model, 'l_id');
     $result .= Html::input('', 'l_id', !empty($lp = LetualProduct::find()->where(['id' => $model->l_id])->one()) ? $lp->article : '', ['class' => 'kv-editable-input form-control']);
     $result .= Html::activeLabel($model, 'r_id');
     $result .= Html::input('', 'r_id', !empty($lp = RivegaucheProduct::find()->where(['id' => $model->r_id])->one()) ? $lp->article : '', ['class' => 'kv-editable-input form-control']);
     $result .= Html::activeLabel($model, 'e_id');
     $result .= Html::input('', 'e_id', !empty($ep = ElizeProduct::find()->where(['id' => $model->e_id])->one()) ? $ep->article : '', ['class' => 'kv-editable-input form-control']);
     $result .= Html::activeLabel($model, 'i_id');
     $result .= Html::input('', 'i_id', !empty($lp = IledebeauteProduct::find()->where(['id' => $model->i_id])->one()) ? $lp->article : '', ['class' => 'kv-editable-input form-control']);
     return $result;
 }