diff --git a/common/modules/product/controllers/ManageController.php b/common/modules/product/controllers/ManageController.php index a00ae0e..c7b8643 100755 --- a/common/modules/product/controllers/ManageController.php +++ b/common/modules/product/controllers/ManageController.php @@ -128,10 +128,6 @@ class ManageController extends Controller $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); if ($model->save() && $model->imagesUpload) { - foreach ($model->images as $image) { - $image->delete(); - } - if ( ($images = $model->imagesUpload()) !== FALSE) { foreach ($images as $image) { $imageModel = new ProductImage(); @@ -159,14 +155,13 @@ class ManageController extends Controller public function actionUpdate($id) { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post())) { $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); if ($model->save()) { - foreach ($model->images as $image) { - $image->delete(); - } +// foreach ($model->images as $image) { +// $image->delete(); +// } if ( ($images = $model->imagesUpload()) !== FALSE) { foreach ($images as $image) { diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php index 5ed9421..d87ffdf 100755 --- a/common/modules/product/models/Product.php +++ b/common/modules/product/models/Product.php @@ -213,7 +213,7 @@ class Product extends \yii\db\ActiveRecord // // } - /*$todel = []; + $todel = []; foreach ($this->variants ? : [] as $_variant) { $todel[$_variant->product_variant_id] = $_variant->product_variant_id; } @@ -229,11 +229,12 @@ class Product extends \yii\db\ActiveRecord } $_variant['product_id'] = $this->product_id; $model->load(['ProductVariant' => $_variant]); + $model->product_id = $this->product_id; $model->save(); } if (!empty($todel)) { ProductVariant::deleteAll(['product_variant_id' => $todel]); - }*/ + } } public function imagesUpload() diff --git a/frontend/views/catalog/product_item.php b/frontend/views/catalog/product_item.php index 995273e..2b40181 100755 --- a/frontend/views/catalog/product_item.php +++ b/frontend/views/catalog/product_item.php @@ -5,13 +5,23 @@ use yii\helpers\Url;