Commit 6a879063f62d64bd3563e33c523157b120322d9e
1 parent
c00ad3cc
remarketing
Showing
1 changed file
with
13 additions
and
1 deletions
Show diff stats
console/controllers/FeedController.php
@@ -32,18 +32,22 @@ class FeedController extends Controller | @@ -32,18 +32,22 @@ class FeedController extends Controller | ||
32 | return Product::find() | 32 | return Product::find() |
33 | ->innerJoin(ProductVariant::tableName(), ProductVariant::tableName() .'.product_id = '. Product::tableName() .'.product_id') | 33 | ->innerJoin(ProductVariant::tableName(), ProductVariant::tableName() .'.product_id = '. Product::tableName() .'.product_id') |
34 | ->where(['and', ProductVariant::tableName().'.status = 0', ProductVariant::tableName().'.stock > 0']) | 34 | ->where(['and', ProductVariant::tableName().'.status = 0', ProductVariant::tableName().'.stock > 0']) |
35 | + ->limit(3) | ||
35 | ->all(); | 36 | ->all(); |
36 | } | 37 | } |
37 | 38 | ||
38 | public function createRow( $product, &$content ){ | 39 | public function createRow( $product, &$content ){ |
39 | if ($this->checkId($product->product_id)) { | 40 | if ($this->checkId($product->product_id)) { |
40 | print $this->count++ . "\r\n"; | 41 | print $this->count++ . "\r\n"; |
42 | + $url = Url::to(['catalog/product', 'product' => $product]); | ||
41 | $content[] = [ | 43 | $content[] = [ |
42 | $product->variant->product_variant_id, | 44 | $product->variant->product_variant_id, |
43 | $product->category->category_id, | 45 | $product->category->category_id, |
44 | $product->category->name, | 46 | $product->category->name, |
45 | $product->name, | 47 | $product->name, |
46 | $product->price.' UAH', | 48 | $product->price.' UAH', |
49 | + $product->images->imageUrl, | ||
50 | + $url, | ||
47 | ]; | 51 | ]; |
48 | } | 52 | } |
49 | } | 53 | } |
@@ -59,13 +63,21 @@ class FeedController extends Controller | @@ -59,13 +63,21 @@ class FeedController extends Controller | ||
59 | 63 | ||
60 | public function actionProcess() { | 64 | public function actionProcess() { |
61 | 65 | ||
66 | + $config = ArrayHelper::merge( | ||
67 | + require(__DIR__ . '/../../frontend/config/main.php'), | ||
68 | + require(__DIR__ . '/../../common/config/main.php') | ||
69 | + | ||
70 | + ); | ||
71 | + | ||
72 | + Yii::$app->urlManager->addRules($config['components']['urlManager']['rules']); | ||
73 | + | ||
62 | $dirName = Yii::getAlias('@frontend').'/web'; | 74 | $dirName = Yii::getAlias('@frontend').'/web'; |
63 | $filename = 'feed.csv'; | 75 | $filename = 'feed.csv'; |
64 | setlocale(LC_ALL, 'ru_RU.CP1251'); | 76 | setlocale(LC_ALL, 'ru_RU.CP1251'); |
65 | 77 | ||
66 | $handle = fopen($dirName .'/'. $filename, "w"); | 78 | $handle = fopen($dirName .'/'. $filename, "w"); |
67 | 79 | ||
68 | - $content[] = ['ID', 'ID2', 'Item Category', 'Item title', 'Price']; | 80 | + $content[] = ['ID', 'ID2', 'Item Category', 'Item title', 'Price', 'Final URL', 'Image URL']; |
69 | 81 | ||
70 | foreach ($this->getProducts() as $product) { | 82 | foreach ($this->getProducts() as $product) { |
71 | $this->createRow($product, $content); | 83 | $this->createRow($product, $content); |