Commit 71bd843eef31b26aacd35c8a827c3450807a9731
1 parent
5de26717
-Some fixes
Showing
3 changed files
with
14 additions
and
2 deletions
Show diff stats
common/modules/product/models/Product.php
| @@ -208,6 +208,17 @@ | @@ -208,6 +208,17 @@ | ||
| 208 | // return !empty( $image ) ? $image->imageUrl : '/images/no_photo.png'; | 208 | // return !empty( $image ) ? $image->imageUrl : '/images/no_photo.png'; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | + public function getMainImageUrl() | ||
| 212 | + { | ||
| 213 | + $image = $this->getImage()->andWhere([ | ||
| 214 | + 'product_variant_id' => NULL, | ||
| 215 | + ])->one(); | ||
| 216 | + if(!empty($image)) { | ||
| 217 | + return $image->imageUrl; | ||
| 218 | + } | ||
| 219 | + return null; | ||
| 220 | + } | ||
| 221 | + | ||
| 211 | /** | 222 | /** |
| 212 | * @return \yii\db\ActiveQuery | 223 | * @return \yii\db\ActiveQuery |
| 213 | */ | 224 | */ |
frontend/views/catalog/_product_list.php
| @@ -21,8 +21,9 @@ use yii\widgets\ListView; | @@ -21,8 +21,9 @@ use yii\widgets\ListView; | ||
| 21 | 'product' => $model->alias, | 21 | 'product' => $model->alias, |
| 22 | 'variant' => $model->variant->sku, | 22 | 'variant' => $model->variant->sku, |
| 23 | ])?>"> | 23 | ])?>"> |
| 24 | + <div class="picture" style="background-image:url('<?php echo ArtboxImageHelper::getImageSrc($model->getImageUrl(), 'product_list_item'); ?>');"></div> | ||
| 24 | <?php | 25 | <?php |
| 25 | - echo ArtboxImageHelper::getLazyDiv($model->getImageUrl(), 'product_list_item', ['class' => 'picture']); | 26 | +// echo ArtboxImageHelper::getLazyDiv($model->getImageUrl(), 'product_list_item', ['class' => 'picture']); |
| 26 | ?> | 27 | ?> |
| 27 | <div class="title_1"><?php echo $model->name; ?></div> | 28 | <div class="title_1"><?php echo $model->name; ?></div> |
| 28 | <div class="title_2"><?php echo $model->variant->sku; ?></div> | 29 | <div class="title_2"><?php echo $model->variant->sku; ?></div> |
frontend/views/category/collection.php
| @@ -54,7 +54,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -54,7 +54,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 54 | 'variant' => $product->variant->sku, | 54 | 'variant' => $product->variant->sku, |
| 55 | ]); ?>" alt="nabuco"> | 55 | ]); ?>" alt="nabuco"> |
| 56 | <div class="label"><span><?php echo $product->name; ?></span></div> | 56 | <div class="label"><span><?php echo $product->name; ?></span></div> |
| 57 | - <?php echo ArtboxImageHelper::getImage($product->getImageUrl(), 'collections_thumb');?> | 57 | + <?php echo ArtboxImageHelper::getImage($product->getMainImageUrl(), 'collections_thumb');?> |
| 58 | </a> | 58 | </a> |
| 59 | <?php } ?> | 59 | <?php } ?> |
| 60 | </div> | 60 | </div> |