public function actionCreate()
{
$model = new Product();
if(<тут должно быть условие>){
$model->category_id='2';
$model->author_id=$app->user->identity['id'];
$model->name='name';
$model->content='content';
$model->price='0';
$model->keywords='NULL';
$model->description='NULL';
$model->hit='0';
$model->new='0';
return $model->save();
}
}
public function actionCreate()
{
$product_count = Product::find()->count();
while ($product_count < 10) {
$model = new Product;
$model->category_id='2';
$model->author_id=$app->user->identity['id'];
$model->name='name';
$model->content='content';
$model->price='0';
$model->keywords='NULL';
$model->description='NULL';
$model->hit='0';
$model->new='0';
if ($model->save()) {
$product_count++;
}
}
}