Commit 1bdd164618d5be24eceee94f161d9beffd2bfed5
1 parent
a2aae8fa
-
Showing
3 changed files
with
20 additions
and
14 deletions
Show diff stats
common/modules/product/controllers/ManageController.php
... | ... | @@ -128,10 +128,6 @@ class ManageController extends Controller |
128 | 128 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); |
129 | 129 | |
130 | 130 | if ($model->save() && $model->imagesUpload) { |
131 | - foreach ($model->images as $image) { | |
132 | - $image->delete(); | |
133 | - } | |
134 | - | |
135 | 131 | if ( ($images = $model->imagesUpload()) !== FALSE) { |
136 | 132 | foreach ($images as $image) { |
137 | 133 | $imageModel = new ProductImage(); |
... | ... | @@ -159,14 +155,13 @@ class ManageController extends Controller |
159 | 155 | public function actionUpdate($id) |
160 | 156 | { |
161 | 157 | $model = $this->findModel($id); |
162 | - | |
163 | 158 | if ($model->load(Yii::$app->request->post())) { |
164 | 159 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); |
165 | 160 | |
166 | 161 | if ($model->save()) { |
167 | - foreach ($model->images as $image) { | |
168 | - $image->delete(); | |
169 | - } | |
162 | +// foreach ($model->images as $image) { | |
163 | +// $image->delete(); | |
164 | +// } | |
170 | 165 | |
171 | 166 | if ( ($images = $model->imagesUpload()) !== FALSE) { |
172 | 167 | foreach ($images as $image) { | ... | ... |
common/modules/product/models/Product.php
... | ... | @@ -213,7 +213,7 @@ class Product extends \yii\db\ActiveRecord |
213 | 213 | // |
214 | 214 | // } |
215 | 215 | |
216 | - /*$todel = []; | |
216 | + $todel = []; | |
217 | 217 | foreach ($this->variants ? : [] as $_variant) { |
218 | 218 | $todel[$_variant->product_variant_id] = $_variant->product_variant_id; |
219 | 219 | } |
... | ... | @@ -229,11 +229,12 @@ class Product extends \yii\db\ActiveRecord |
229 | 229 | } |
230 | 230 | $_variant['product_id'] = $this->product_id; |
231 | 231 | $model->load(['ProductVariant' => $_variant]); |
232 | + $model->product_id = $this->product_id; | |
232 | 233 | $model->save(); |
233 | 234 | } |
234 | 235 | if (!empty($todel)) { |
235 | 236 | ProductVariant::deleteAll(['product_variant_id' => $todel]); |
236 | - }*/ | |
237 | + } | |
237 | 238 | } |
238 | 239 | |
239 | 240 | public function imagesUpload() | ... | ... |
frontend/views/catalog/product_item.php
... | ... | @@ -5,13 +5,23 @@ use yii\helpers\Url; |
5 | 5 | <li class="item"> |
6 | 6 | <div class="boxitem"> |
7 | 7 | <div class="pixbox"> |
8 | - <a href="<?= Url::to([ | |
9 | - 'catalog/product', | |
10 | - 'product' => $product]) | |
11 | - ?>"> | |
8 | + <a href="<?= Url::to(['catalog/product', 'product' => $product]) ?>"> | |
12 | 9 | <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->imageUrl, 'list')?> |
13 | 10 | </a> |
14 | 11 | </div> |
12 | + <?php if(!empty($product->is_top) || !empty($product->is_new) || !empty($product->akciya)) :?> | |
13 | + <ul class="product-special"> | |
14 | + <?php if(!empty($product->is_top)) :?> | |
15 | + <li class="top">top </li> | |
16 | + <?php endif?> | |
17 | + <?php if(!empty($product->is_new)) :?> | |
18 | + <li class="new">new </li> | |
19 | + <?php endif?> | |
20 | + <?php if(!empty($product->akciya)) :?> | |
21 | + <li class="promo">promo </li> | |
22 | + <?php endif?> | |
23 | + </ul> | |
24 | + <?php endif?> | |
15 | 25 | <a href="<?= Url::to([ |
16 | 26 | 'catalog/product', |
17 | 27 | 'product' => $product]) | ... | ... |