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 | 32 | return Product::find() |
| 33 | 33 | ->innerJoin(ProductVariant::tableName(), ProductVariant::tableName() .'.product_id = '. Product::tableName() .'.product_id') |
| 34 | 34 | ->where(['and', ProductVariant::tableName().'.status = 0', ProductVariant::tableName().'.stock > 0']) |
| 35 | + ->limit(3) | |
| 35 | 36 | ->all(); |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | public function createRow( $product, &$content ){ |
| 39 | 40 | if ($this->checkId($product->product_id)) { |
| 40 | 41 | print $this->count++ . "\r\n"; |
| 42 | + $url = Url::to(['catalog/product', 'product' => $product]); | |
| 41 | 43 | $content[] = [ |
| 42 | 44 | $product->variant->product_variant_id, |
| 43 | 45 | $product->category->category_id, |
| 44 | 46 | $product->category->name, |
| 45 | 47 | $product->name, |
| 46 | 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 | 63 | |
| 60 | 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 | 74 | $dirName = Yii::getAlias('@frontend').'/web'; |
| 63 | 75 | $filename = 'feed.csv'; |
| 64 | 76 | setlocale(LC_ALL, 'ru_RU.CP1251'); |
| 65 | 77 | |
| 66 | 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 | 82 | foreach ($this->getProducts() as $product) { |
| 71 | 83 | $this->createRow($product, $content); | ... | ... |