Based on the application "blog" from the demos folder, created the commands folder in protected, and there - the products_import.php file.
Here are its contents:
<?php class ProductsImportCommand extends CConsoleCommand { public function actionIndex() { try { $products = Yii::app()->db->createCommand() ->select('product.id, product.url, product.name, product.price, product.price_old, product_section.name, product_category.name, product_img.name') ->from('product') ->join('product_assignment, product_section, product_category, product_img', 'product.id=product_assignment.product_id AND product_section.id=product_assignment.section_id AND product_category.id=product_assignment.category_id') ->order('product_img.type desc') ->queryAll(); $output = fopen('product_import.csv', 'w', ','); fputcsv($output, array('product.id', 'product.url', 'product.name', 'product.price', 'product.price_old', 'product_section.name', 'product_category.name', 'product_img.name')); foreach($products as $product) { fputcsv($output, $product); } fclose($output); } catch (Exception $e) { $this->logger->error($e->getMessage()); } } } Then he tried to start yicc ProductsImport index, but nothing is created, in the console he writes that only 4 standard yiic commands are available. What could be the problem?
UPD: Now it works. But where in the code of the SQL query may be an error, tell me, please? If you comment it out - is created.