/** * Creates a new StoreProduct model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new StoreProduct(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionPairingProducts() { if (Yii::$app->request->isAjax) { /* @var StoreProduct $storeProduct */ $storeProduct = new StoreProduct(); $storeProduct->store_id = $_POST['storeId']; $storeProduct->product_id = $_POST['productId']; $storeProduct->price = $_POST['price']; if ($storeProduct->save()) { return 'save :)'; } else { return 'not save :('; } } else { $dataProvider = new ActiveDataProvider(['query' => Product::find()]); return $this->render('pairing-products', ['dataProvider' => $dataProvider]); } }