limit(100)->all(); } public function checkUrl($url){ if(!in_array($url, $this->urlList)){ $this->urlList[] = $url; 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]; // } $variants = $product->variants; foreach ($variants as $variant) { print $variant->product_name."\r\n"; } } public function actionProcess() { $dirName = Yii::getAlias('@frontend').'/web'; $filename = 'feed.csv'; setlocale(LC_ALL, 'ru_RU.CP1251'); $handle = fopen($dirName .'/'. $filename, "w"); $content[] = ['ID', 'ID2', 'Item Category', 'Item title', 'Item description', 'Price']; $content[] = ['ID', 'ID2', 'Item Category', 'Item title', 'Item description', 'Price']; foreach ($this->getProducts() as $product) { $this->createRow($product, $content); } foreach ($content as $item) { fputcsv($handle, $item); } fclose($handle); print $dirName .'/'. $filename; } }