/**
  * Finds the IledebeauteProduct model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return IledebeauteProduct the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = IledebeauteProduct::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 2
0
 /**
  * @return int
  */
 public function actionIle()
 {
     $query = new Query();
     $rows = $query->from('lproduct')->match(new Expression(':match', ['match' => '@(description)' . \Yii::$app->sphinx->escapeMatchValue('база         макияж     под')]))->all();
     print_r($rows);
     print_r(IledebeauteProduct::findOne(['id' => $rows[0]['id']])->toArray());
     die;
     return $rows;
 }
 /**
  * Сохраняем результаты из массива
  *
  * @param $result
  * @param $link
  */
 private function saveResult($result, $link)
 {
     foreach ($result['items'] as $item) {
         if (!empty($item['article'])) {
             $product = IledebeauteProduct::findOne(['article' => $item['article']]);
             if (!$product) {
                 $product = new IledebeauteProduct();
             }
             $product->brand = $this->clearBrand($result['brand']);
             $product->title = $result['title'];
             $product->article = $item['article'];
             $product->showcases_new = $item['showcases_new'];
             $product->showcases_sale = $item['showcases_sale'];
             $product->showcases_exclusive = $item['showcases_exclusive'];
             $product->showcases_limit = $item['showcases_limit'];
             $product->showcases_best = $item['showcases_best'];
             $product->new_price = $this->getPrice($item['price']['newPrice']);
             $product->old_price = $this->getPrice($item['price']['oldPrice']);
             $product->category = $link['category'];
             $product->group = $link['group'];
             $product->link = $link['link'];
             $product->sub_category = $link['sub_category'];
             $product->image_link = $item['image'];
             $product->description = $item['description'];
             $product->deleted_at = '0000-00-00 00:00:00';
             $price = new IledebeautePrice();
             $price->article = $item['article'];
             $price->new_price = $this->getPrice($item['price']['newPrice']);
             $price->old_price = $this->getPrice($item['price']['oldPrice']);
             if (!empty($price) && $product->save()) {
                 $price->save();
             }
         }
     }
 }