Commit 9b454120f07abcd78460293826b13eeb698e3c31
1 parent
47f4aeac
remarketing
Showing
1 changed file
with
12 additions
and
14 deletions
Show diff stats
console/controllers/FeedController.php
... | ... | @@ -24,32 +24,30 @@ use yii\web\NotFoundHttpException; |
24 | 24 | |
25 | 25 | class FeedController extends Controller |
26 | 26 | { |
27 | - private $urlList = []; | |
27 | + private $idList = []; | |
28 | 28 | private $count = 1; |
29 | 29 | |
30 | 30 | public function getProducts() { |
31 | 31 | return Product::find()->limit(100)->all(); |
32 | 32 | } |
33 | 33 | |
34 | - public function checkUrl($url){ | |
35 | - if(!in_array($url, $this->urlList)){ | |
36 | - $this->urlList[] = $url; | |
34 | + public function createRow( $product, &$content ){ | |
35 | + if ($this->checkId($product->product_id)) { | |
36 | + print $product->product_id."\r\n"; | |
37 | + //print $this->count++ . "\n"; | |
38 | + $content[] = [$product->product_id, $product->name, $product->price]; | |
39 | + } | |
40 | + } | |
41 | + | |
42 | + public function checkId($id){ | |
43 | + if(!in_array($id, $this->idList)){ | |
44 | + $this->idList[] = $id; | |
37 | 45 | return true; |
38 | 46 | } else { |
39 | 47 | return false; |
40 | 48 | } |
41 | 49 | } |
42 | 50 | |
43 | - public function createRow( $product, &$content ){ | |
44 | -// $url = Url::to(['catalog/product', 'product' => $product]); | |
45 | -// if($this->checkUrl($url)){ | |
46 | -// print $url; | |
47 | -// print $this->count++ . "\n"; | |
48 | -// $content[] = [$url]; | |
49 | -// } | |
50 | - print $product->product_id."\r\n"; | |
51 | - } | |
52 | - | |
53 | 51 | public function actionProcess() { |
54 | 52 | |
55 | 53 | $dirName = Yii::getAlias('@frontend').'/web'; | ... | ... |