diff --git a/console/controllers/FeedController.php b/console/controllers/FeedController.php index e4b7168..975231a 100644 --- a/console/controllers/FeedController.php +++ b/console/controllers/FeedController.php @@ -24,32 +24,30 @@ use yii\web\NotFoundHttpException; class FeedController extends Controller { - private $urlList = []; + private $idList = []; private $count = 1; public function getProducts() { return Product::find()->limit(100)->all(); } - public function checkUrl($url){ - if(!in_array($url, $this->urlList)){ - $this->urlList[] = $url; + public function createRow( $product, &$content ){ + if ($this->checkId($product->product_id)) { + print $product->product_id."\r\n"; + //print $this->count++ . "\n"; + $content[] = [$product->product_id, $product->name, $product->price]; + } + } + + public function checkId($id){ + if(!in_array($id, $this->idList)){ + $this->idList[] = $id; return true; } else { return false; } } - public function createRow( $product, &$content ){ -// $url = Url::to(['catalog/product', 'product' => $product]); -// if($this->checkUrl($url)){ -// print $url; -// print $this->count++ . "\n"; -// $content[] = [$url]; -// } - print $product->product_id."\r\n"; - } - public function actionProcess() { $dirName = Yii::getAlias('@frontend').'/web'; -- libgit2 0.21.4