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,10 +128,6 @@ class ManageController extends Controller | ||
| 128 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); | 128 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); |
| 129 | 129 | ||
| 130 | if ($model->save() && $model->imagesUpload) { | 130 | if ($model->save() && $model->imagesUpload) { |
| 131 | - foreach ($model->images as $image) { | ||
| 132 | - $image->delete(); | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | if ( ($images = $model->imagesUpload()) !== FALSE) { | 131 | if ( ($images = $model->imagesUpload()) !== FALSE) { |
| 136 | foreach ($images as $image) { | 132 | foreach ($images as $image) { |
| 137 | $imageModel = new ProductImage(); | 133 | $imageModel = new ProductImage(); |
| @@ -159,14 +155,13 @@ class ManageController extends Controller | @@ -159,14 +155,13 @@ class ManageController extends Controller | ||
| 159 | public function actionUpdate($id) | 155 | public function actionUpdate($id) |
| 160 | { | 156 | { |
| 161 | $model = $this->findModel($id); | 157 | $model = $this->findModel($id); |
| 162 | - | ||
| 163 | if ($model->load(Yii::$app->request->post())) { | 158 | if ($model->load(Yii::$app->request->post())) { |
| 164 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); | 159 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); |
| 165 | 160 | ||
| 166 | if ($model->save()) { | 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 | if ( ($images = $model->imagesUpload()) !== FALSE) { | 166 | if ( ($images = $model->imagesUpload()) !== FALSE) { |
| 172 | foreach ($images as $image) { | 167 | foreach ($images as $image) { |
common/modules/product/models/Product.php
| @@ -213,7 +213,7 @@ class Product extends \yii\db\ActiveRecord | @@ -213,7 +213,7 @@ class Product extends \yii\db\ActiveRecord | ||
| 213 | // | 213 | // |
| 214 | // } | 214 | // } |
| 215 | 215 | ||
| 216 | - /*$todel = []; | 216 | + $todel = []; |
| 217 | foreach ($this->variants ? : [] as $_variant) { | 217 | foreach ($this->variants ? : [] as $_variant) { |
| 218 | $todel[$_variant->product_variant_id] = $_variant->product_variant_id; | 218 | $todel[$_variant->product_variant_id] = $_variant->product_variant_id; |
| 219 | } | 219 | } |
| @@ -229,11 +229,12 @@ class Product extends \yii\db\ActiveRecord | @@ -229,11 +229,12 @@ class Product extends \yii\db\ActiveRecord | ||
| 229 | } | 229 | } |
| 230 | $_variant['product_id'] = $this->product_id; | 230 | $_variant['product_id'] = $this->product_id; |
| 231 | $model->load(['ProductVariant' => $_variant]); | 231 | $model->load(['ProductVariant' => $_variant]); |
| 232 | + $model->product_id = $this->product_id; | ||
| 232 | $model->save(); | 233 | $model->save(); |
| 233 | } | 234 | } |
| 234 | if (!empty($todel)) { | 235 | if (!empty($todel)) { |
| 235 | ProductVariant::deleteAll(['product_variant_id' => $todel]); | 236 | ProductVariant::deleteAll(['product_variant_id' => $todel]); |
| 236 | - }*/ | 237 | + } |
| 237 | } | 238 | } |
| 238 | 239 | ||
| 239 | public function imagesUpload() | 240 | public function imagesUpload() |
frontend/views/catalog/product_item.php
| @@ -5,13 +5,23 @@ use yii\helpers\Url; | @@ -5,13 +5,23 @@ use yii\helpers\Url; | ||
| 5 | <li class="item"> | 5 | <li class="item"> |
| 6 | <div class="boxitem"> | 6 | <div class="boxitem"> |
| 7 | <div class="pixbox"> | 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 | <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->imageUrl, 'list')?> | 9 | <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->imageUrl, 'list')?> |
| 13 | </a> | 10 | </a> |
| 14 | </div> | 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 | <a href="<?= Url::to([ | 25 | <a href="<?= Url::to([ |
| 16 | 'catalog/product', | 26 | 'catalog/product', |
| 17 | 'product' => $product]) | 27 | 'product' => $product]) |