From 1bdd164618d5be24eceee94f161d9beffd2bfed5 Mon Sep 17 00:00:00 2001 From: Karnovsky A Date: Fri, 20 May 2016 16:15:17 +0300 Subject: [PATCH] - --- common/modules/product/controllers/ManageController.php | 11 +++-------- common/modules/product/models/Product.php | 5 +++-- frontend/views/catalog/product_item.php | 18 ++++++++++++++---- 3 files changed, 20 insertions(+), 14 deletions(-) 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;
  • + is_top) || !empty($product->is_new) || !empty($product->akciya)) :?> +
      + is_top)) :?> +
    • top 
    • + + is_new)) :?> +
    • new 
    • + + akciya)) :?> +
    • promo 
    • + +
    +